Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8422995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:36:42+00:00 2026-06-10T03:36:42+00:00

In my backbone app, I need to provide a fallback for each required file,

  • 0

In my backbone app, I need to provide a fallback for each required file, in the case that the CDN that delivers them fails.

I have tried overwriting require.onError like so:

require.onError = function (err) {
    if (err.requireType === 'timeout') {
        var url = err.requireModules;

        if (!!~url.indexOf("jquery/"))
            console.warn("CDN timed out, falling back to local jQuery.js")
            require(["libs/jquery"]);
            return;
        if (!!~url.indexOf("jqueryui/"))
            console.warn("CDN timed out, falling back to local jQueryUI.js")
            require(["libs/jqueryui"]);
            return;
        if (!!~url.indexOf("underscore"))
            console.warn("CDN timed out, falling back to local underscore.js")
            require(["libs/underscore"]);
            return;
        if (!!~url.indexOf("backbone"))
            console.warn("CDN timed out, falling back to local backbone.js")
            require(["libs/backbone"]);
            return;
    }
}

The problem is that this will asynchronously load the fallback files. I need these files to load in order, just like the original require statement, where I use the order! plugin.

With the overridden onError: when the CDN fails to load, the fallback load is started, but not waited for. This presents a problem because the scripts are ordered to be loaded based on their dependencies. Here is a look at my original require statement, that depends on the CDN:

require([
    "order!http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
    "order!http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js",
    "order!http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js",
    "order!http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js",
    "order!utils/date",
    "order!core/core",
    "order!core/errors",
    "order!core/constants"
], function() {
    ...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:36:44+00:00Added an answer on June 10, 2026 at 3:36 am

    What version of RequireJS are you using? It seems you might want to configure jQuery’s fallback as a path in your config, then set up jQuery as a dependency on the other modules that need it. If you’re using ~> 2.0, something like (untested):

    // in your requirejs config
    requirejs.config({
        //To get timely, correct error triggers in IE, force a define/shim exports 
        // check.
        enforceDefine: true,
        paths: {
            jquery: [
                'http://somecdn.com/jquery.min', // your cdn
                'lib/jquery' // your fallback
            ],
            jqueryui: "http://somecdn.com/jquery-ui.min.js"
        },
        shim: {
          jqueryui: ['jquery']
        }
    });
    
    // then in your requires
    require([jquery, jqueryui, foo, bar], function($) {
        // stuff
    });
    

    They talk about how to do it in the wiki. If you are not using v2.x, there is a method for handling that here too.

    If all the modules are configured to specify their own dependencies, you shouldn’t need to worry about the order! directives either.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a Backbone app and I need to have automated tests. I
We have a backbone.js app that displays a number of forms to the user.
I'm using Backbone.js in a Rails app and I need to do file uploads
in backbone we have an app that uses an event Aggregator, located on the
Basically what I need is to do something like this App.CommentView = Backbone.View.extend({ className:
I have the following code in my Backbone app, Is there a way to
I'm building an app using Brunch and Backbone.js that is to include nested menus.
I am using C++ as the app backbone and Objective-C for the GUI, that's
I have a web app and I need print the data into pdf. In
I have a question about the architecture of a backbone.js web app. Let's say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.