Fallback JS - JavaScript library for dynamically loading CSS and JS files

Overview

Fallback JS

Fallback JS ========

WORKS IN LEGACY AND MODERN BROWSERS!

Tested and working in Chrome, Firefox, Safari and IE 6 - 10!

Fallback JS is a tiny library that allows you to load both your JavaScript and CSS libraries after your page has already loaded. The library also allows you to specify "failovers" or "fallbacks" for each of your libraries, this way in case one of those external libraries you're using happens to fail, you won't be leaving your users with a dysfunctional website. Just because someone else's website breaks, it doesn't mean that yours should!

Downloads

SEE WORKING DEMOS WITH SOURCE CODE AT http://plnkr.co/tags/fallbackjs

Introduction

Getting Started

Quick and easy demonstration.

To let you dive right in, we're going to provide you with a sample of code below. If you want to learn more you can read through the rest of this page for all of the technical details. This quick and easy demonstration should be enough for you to understand how to use the library and implement it in your code.

// Script block to execute Fallback JS ">
// Include the Fallback JS library.
<script src="fallback.min.js">script>

// Script block to execute Fallback JS
<script>

	// Here we actually invoke Fallback JS to retrieve the following libraries for the page.
	fallback.load({
		// Include your stylesheets, this can be an array of stylesheets or a string!
		page_css: 'index.css',
		global_css: ['public.css', 'members.css'],

		// JavaScript library. THE KEY MUST BE THE LIBRARIES WINDOW VARIABLE!
		JSON: '//cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2.min.js',

		// Here goes a failover example. The first will fail, therefore Fallback JS will load the second!
		jQuery: [
			'//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.FAIL_ON_PURPOSE.min.js',
			'//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js',
			'//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.0/jquery.min.js'
		],

		'jQuery.ui': [
			'//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js',
			'//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js',
			'//js/loader.js?i=vendor/jquery-ui.min.js'
		]
	}, {
		// Shim jQuery UI so that it will only load after jQuery has completed!
		shim: {
			'jQuery.ui': ['jQuery']
		},

		callback: function(success, failed) {
			// success - object containing all libraries that loaded successfully.
			// failed - object containing all libraries that failed to load.

			// All of my libraries have finished loading!

			// Execute my code that applies to all of my libraries here!
		}
	});

	fallback.ready(['jQuery'], function() {
		// jQuery Finished Loading

		// Execute my jQuery dependent code here!
	});

	fallback.ready(['jQuery', 'JSON'], function() {
		// jQuery and JSON Finished Loading

		// Execute my jQuery + JSON dependent code here!
	});

	fallback.ready(function() {
		// All of my libraries have finished loading!

		// Execute my code that applies to all of my libraries here!
	});
script>

Why Fallback JS?

Unlimited failovers, and size that does matter!

The sole purpose of Fallback JS is to make it extremely easy for you as a developer to load as many external JavaScript and/or CSS libraries that you want with the ability to have as many failovers as you want without you having to write custom code or run through extra loops to achieve this goal.

Along with this premise, the filesize the extremely small, the main purpose of loading JavaScript files after your website has already loaded is to decrease your page load time (see below). You want your users to load as little as possible so you website can load as fast as it possibly can. Think outside the box. All of your users won't always be on high speed internet connections, and we all know how slow surfing the web can sometimes be on mobile devices.

Improving Page Load Times

Speed is important!

An extremely common way of coding websites throughout the internet for years has been to put your javascript and stylesheet references in the of your HTML. By doing this you're forcing the browser to wait for those libraries to load before it actually displays the page to the user.

Alternatively there are a few ways around this. First you can put your references at the bottom of the page before closing the tag. This alone will boost the speed of your page loads. To boost the page load speed even further, you simply don't reference those libraries at all in the HTML and instead you can let JavaScript load those libraries for you after the page load. This is exactly what Fallback JS does for you!

Failovers For Your Libraries

So that your website doesn't break!

So you found all of these great CDNs that host popular libraries such as jQuery, Dojo and Underscore.js just to name a few. You don't want to waste bandwidth on libraries that you can include for free on your website, that's understandable. But what happens when one of those CDNs you're using goes down for maintenance? Or mysteriously stops working out of the blue? Your website breaks! That's what happens!

Don't get stuck leaving your users with a dysfunctional website because of someone else's mistakes. You should always have multiple failovers for any external library you decide to bundle for your website.

Fallback JS makes this extremely easy for you to integrate into your website. Not only can you have as many failovers as you want for each of your libraries, but you can also implement shimming as well. Shimming for example is the ability to load certain libraries if other libraries have finished loading. Case by example jQuery UI depends on jQuery. You simply cannot load jQuery UI before jQuery has finished loading. In this instance you would shim jQuery UI to load after jQuery has completed.

What is shimming?

shim
verb (used with object)

	"to fill out or bring to a level by inserting a shim or shims."

	"to modify a load, clearance, or magnetic field by the use of shims"

	Source: http://dictionary.reference.com/browse/shim/

When we refer to shims or shimming we are referring to modifying the load context of your libraries that you specify. For instance there will be cases where you cannot load certain libraries until other libraries have first loaded. One of the main cases by example that is pointed out is jQuery UI. jQuery UI cannot be loaded until jQuery has loaded, therefore jQuery must load first, and we must shim jQuery UI to load only after jQuery has finished.

API

ready

fallback.ready([libraries], callback)

[libraries] array optional

callback function optional

Executes your function provided to the callback as soon as your libraries have finished loading. The [libraries] array parameter is optional, if an array is not passed in the code will assume that the first parameter passed is the callback and in turn will only execute once all of your libraries have finished loading. If you provide the [libraries] array, the callback will only trigger your callback when those libraries provided have finished loading. You may define the ready function multiple times throughout your code.

fallback.ready(function() {
	// All of my libraries are loaded. Execute my code here!
});

fallback.ready(['jQuery', 'jQuery.ui'], function() {
	// jQuery and jQuery UI are finished. Spin up my animation code here!
});

load

fallback.load({libraries}, {options})

{libraries} object optional

Expects to be an object containing a key value pair where the key is the library's window variable, and the value is the url to fetch the library from. The keys must be the window variable name of the library you're loading if it's a JavaScript library. This is only relevant for JavaScript libraries and not StyleSheets, for StyleSheets you can name them however you please. For example jQuery's key would be jQuery since window.jQuery exists after jQuery has finished loading. This is required to provide support for legacy browsers.

The values of your keys can be either a string, an array or an object. If you happen to pass an array as the value Fallback JS will iterate through each of items in the order provided until one of them has loaded successfully. This provides the failover functionality so that if your first request fails, it will try the next item in the array to load for the library in question. If you pass an object as the value then the object must have a urls property representing the failover URLs. Passing an object gives you the added benefit of being able to specify integrity and crossorigin properties to ensure subresource integrity when loading from a CDN. A subresource integrity check failure is treated the same way as any other failure to load the library, meaning Fallback JS will attempt to load the library using the next URL in the array. This protects you from compromised CDNs where the contents of the library have been altered for potentially malicious reasons.

{
	// The key for stylesheets **doesn't matter**, name them however you like.
	css: 'index.css',

	// You have the option to pass a string as your value
	JSON: '//cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2.min.js',

	// You have the option to pass an array as your value
	jQuery: [
		'//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.**FAILONPURPOSE** .min.js',
		'//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js',
		'//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.0/jquery.min.js',
		'//localhost/js/jquery.min.js'
	],

  // You have the option to pass an object as your value so that you can specify additional properties such as
  // `integrity` and `crossorigin` values to ensure [subresource integrity](https://www.w3.org/TR/SRI/) when loading files from a CDN.
  // Note that the **key** correlates to jQuery UI's window variable.
	'jQuery.ui': {
        urls: [
            '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js',
            '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js',
            '//js/loader.js?i=vendor/jquery-ui.min.js',
            '//localhost/js/jquery-ui.min.js'
        ],
        integrity: 'sha384-O4jIYc8wiFPNf25AwmeP5qRInqzSLJuM9t+u843Al1M/OO67y4JsVjlJGaUl4N7J',
        crossorigin: 'anonymous'
    }
}

options object optional

Expects to be an object containing a key value pair where the key is either shim or callback.

> shim object optional

Expects its value to be an object containing a key value pair where the key is the library you want to shim, and the value is an array of libraries you want to finish loading first before attempting to actually load the library specified as the key.

> callback function optional

Expects to be a function and will accept 2 parameters success and failed which will be returned as objects. The first parameter will be success which is an object of all the libraries that were successfully loaded. The second parameter will be failed which is an object of all the libraries that failed to load.

{
	// Shimming example. We only want to load jQuery UI after jQuery has loaded!
	// Otherwise if jQuery UI loads before jQuery we will get JavaScript errors.
	shim: {
		'jQuery.ui': ['jQuery']
	},

	// Here you have the ability to place callback within the object.
	// This is the equivalent of calling fallback.ready()
	callback: function(success, failed) {
		// Inline Callback
	}
}

About

License

The MIT License (MIT)

Copyright (c) 2013 Dolox Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Support

We use GitHub!

Any questions, suggestions or bugs should all be submitted to the issues section of the project's GitHub repository.

Comments
  • CORS

    CORS "Access Denied" error in Internet Explorer 11 when loading CSS file from remote server

    I'm only seeing this problem in Internet Explorer 11. (Haven't tested IE9 or IE10.)

    Using fallback.js version 1.1.1, error occurs on Line 208:

    if (stylesheet.rules) {

    in function fallback.css.check()

    Test page exhibiting the problem (IE11) is here:

    http://win-soft.s3.amazonaws.com/public/fallback-test.html

    bug 
    opened by cormip 15
  • v2 Draft

    v2 Draft

    I'm looking to get feedback on the v2 draft.

    -- UPDATED -- Track specification and progress via: https://github.com/dolox/fallback/tree/v2

    Everyone I tagged here either submitted a bug in the past or was involved somehow in the project. I would love to hear your feedback on this.

    Goals:

    • Full test suite runner, Mocha + Karma, that will automatically run in all the browsers.
    • Short hand code galore, easier for users to implement and a lot faster to code with. Example instead of writing fallback.require you would write req. Instead of fallback.config, simply use conf.
    • Ability to be able to explicitly load CSS/IMG/JS files. Saving users from typing file extension such as .css and .js, and letting the library automatically add them, saving on excess code. Prefixes css files with css! and image files with img!. Probably fonts as well prefixing with font!. Not sure how I feel about the exclamation mark, I think I like ':" better. Would like to hear what others think.

    Example:

    fallback.config({
        urls: {
            'img!logo': [
                '//www.amazoncdn.com/logo.png',
                '//www.amazoncdn.com/logo2.png'
            ],
    
            'css!bootstrap': [
                '//www.bootstrapcdn.com/bootstrap', // .css will automatically be suffixed by the library
                '//www.amazoncdn.com/bootstrap'
            ]
        }
    };
    
    fallback.config({
        urls: {
            'img:logo': [
                '//www.amazoncdn.com/logo.png',
                '//www.amazoncdn.com/logo2.png'
            ]
        }
    };
    
    fallback.config({
        urls: {
            'img$logo': [
                '//www.amazoncdn.com/logo.png',
                '//www.amazoncdn.com/logo2.png'
            ]
        }
    };
    

    Instead of css!bootstrap, maybe possible using:instead. So:css:bootstrap`.

    • CLI that directly integrates with Bower. I hope to be able to type from the CLI fallback install angular, and when I go ahead and do that, the CLI would use bower for the install, but then automatically append the library that bower just installed to your Fallback config file so we (the users) don't have to go digging and hand typing our paths. Full automation. You type in the CLI, it automatically adds to your config, your done.
    • Comments glare, and ability to turn on debugging which would spit on console messages to better help/guide users.
    • RequireJS drop in replacement. Not looking to rewrite the entire RequireJS library, but am looking to expand on some of the good parts of it, all while trying to keep it simple. One of the reasons I wrote this library was because you have to become a RequireJS master (reading the whole docs) just to get it fully working right (or a full understanding), which is exactly what I don't want to happen here. I want to give users the ability to use AMD, but not enforce it. Whether they use it or not, is up to them. I also want to leave using globals as an option that way users are not constrained to using single/multiple minify softwares just to concat their JS libraries. For example, if you're using AMD in the library, window.jQuery would still work, whereas with RequireJS it won't. I was using RequireJS with a project, and I wound up wasting hours trying to fix the project to work right with concatenating and minifying files with their r.js library, because I had no choice but to use their r.js library. I did a lot of googling on that matter, I know I'm not alone in that complicated mess of confusion.
    • Easier way for members to contribute by specifying guidelines. https://github.com/rwaldron/idiomatic.js/
    • Small add-on migration libraries for fallback v1.0, and another for RequireJS.
    enhancement 2 - Working 
    opened by sgarbesi 11
  • All CSS files (array) are loaded instead of just the first in the array

    All CSS files (array) are loaded instead of just the first in the array

    The following code loads BOTH css files instead of just the first that successfully loads

    'normalize': [
        'https://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.3/normalize.min.css', 
        'css/third-party/normalize-2.1.3.min.css'
    ]
    

    If it helps i've included a screenshot of the chrome devtools network panel

    fallbackjs-css-fallback

    As you can see both files are loaded

    If this was the intended behavior then how would I go about doing this myself?

    enhancement 
    opened by myhonor16 11
  • libraries without window variable

    libraries without window variable

    Hi, I'd like to use fallback.js - unfortunately, I do think that most files that I'm referencing do not create a window variable - for example, angular dependencies or jquery plugins:

    http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular-route.js http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular-sanitize.js http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular-animate.js

    Is there any way to use the fallback with them?

    Thanks!

    opened by DavideMontersino 7
  • Shimming...

    Shimming...

    Also, one last piece. Not that I haven't already been annoying enough with all of my issue updates here... :) I only mention this here because it took me a while to figure out what you were talking about when you mention "shimming".

    Like your reference in the fallback.js documentation to the word's definition states, a "shim" is essentially "a small piece of something that allows a much larger something to work appropriately". A great example of this is the html5 shim for versions of IE prior to 9. This shim can be used by including

    <script type='text/javascript' src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
    

    in the html of a page. It allows html5 elements to work better on legacy IE browsers. Thus, it's a small piece (file) that allows a larger something (html5) to work appropriately.

    The "shims" that you are defining are really "dependencies". One file (js or css) is dependent upon, or must be loaded before, another file.

    enhancement 
    opened by danSteinway 7
  • CSS gets loaded as a script if the extension of the file is not .css

    CSS gets loaded as a script if the extension of the file is not .css

    Loading a CSS file like this causes the resource to be loaded as a script, as it doesn't end in ".css"

    fallback.load({
          roboto_slab_css : [ '//fonts.googleapis.com/css?family=Roboto+Slab' ],
          //etc
    

    The workaround is something like this:

    fallback.load({
          roboto_slab_css : [ '//fonts.googleapis.com/css?family=Roboto+Slab&.css' ],
          //etc
    
    enhancement 
    opened by MrJamesEllis 6
  • IE10 running code before all libraries are ready

    IE10 running code before all libraries are ready

    The problem is specifically with the fallback.ready() function when the [libraries] array is NOT passed.

    fallback.ready(function() {
        // All of my libraries have finished loading!
        // IE10 will execute this code before all libraries have been loaded
        // Execute my code that applies to all of my libraries here!
    });
    

    Works as expected in IE11, FF & Chrome. Problem was tested in both a real IE10 install as well as using IE11 Debugger with IE10 emulation enabled.

    bug 
    opened by cormip 6
  • Loading issue

    Loading issue

    Hi,

    I am trying to load different js libs from CDN, out of which jQuery and Angular are loading up fine but others including underscore, moment, highcharts, highcharts-ng are just not loading up. Here is what I have :

    fallback.load({
    jQuery: [ '//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.FAIL_ON_PURPOSE.min.js', '//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'
    ], angular: [ '//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js' ], //highcharts: [ // '//code.highcharts.com/highcharts.js' //], //'highcharts-ng': [ // '//rawgit.com/pablojim/highcharts-ng/master/dist/highcharts-ng.js' //], underscore: [ '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js' ]//, //moment: [ // '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.js' //], //'loading-bar': [ // '//cdnjs.cloudflare.com/ajax/libs/angular-loading-bar/0.7.1/loading-bar.min.js' //],

    }, { // Shim different libs so that it will only load after jQuery has completed! shim: { //'underscore' : ['jQuery'] //'highcharts': ['jQuery'], //'highcharts-ng': ['angular'], //'loading-bar': ['angular'] },

    callback: function (success, failed) {
        // success - object containing all libraries that loaded successfully.
        // failed - object containing all libraries that failed to load.
        console.debug('those which loaded');
        console.debug(success);
        console.debug('those which failed');
        console.debug(failed);
        alert('Success');
        // All of my libraries have finished loading!
    
        // Execute my code that applies to all of my libraries here!
    }
    

    });

    fallback.ready(function () { // All of my libraries have finished loading!

    console.debug($);
    console.debug(angular);
    console.debug(underscore);
    // Execute my code that applies to all of my libraries here!
    

    });

    In fallback.ready, underscore stays as undefined, while jQuery and Angular does show version detail. Any help?

    opened by asimnzr 5
  • Shim error in IE8

    Shim error in IE8

    Hi,

    I’m getting the following error in IE8:

    'shim' is null or not an object (fallback.js, line 142, character 4)

    The line is question is:

    if (!me.is_object(options.shim)) {
    

    Any idea how to fix this?

    Thanks,

    Dylan

    opened by dylanparry 5
  • wish: lazy-load libraries

    wish: lazy-load libraries

    One nice feature of require.js is that it supports "lazy loading" libraries. That is, it can avoid loading libraries that are not needed.

    Here's my own use-case for it, and how I think it might be designed and implemented here.

    We use both jQuery and jQuery-UI on our site, and jQuery UI is large enough that we would prefer not to load it on pages where we don't need it.

    With the current design, I could address this by creating two small scripts:

    # Set up definition to load jQuery with fall back
    load-jquery.js
    
    # Set up definition to load jQuery with fall back
    load-jquery-and-jquery-ui.js
    

    I would then load whichever one I needed, and find-and-replace my jQuery "ready" commands to this instead:

    fallback.ready(function() {
        // Completed
    });
    

    The way I would rather use fallback.js to put all my CDN and fallback references in one file, and then I would just declare which ones I needed on a given page, and just those would be loaded.

    Here's how that might look:

    # My local script which calls fallback.load()
    cdn-fallbacks.js
    

    Then, I would replace the jQuery ready() calls depending on which ones I wanted to load:

    # Load everything by default (current behavior)
    fallback.ready(function() {
        // Completed
    });
    
    # explicitly load just jQuery
    fallback.ready(['jQuery'],function() {
        // Completed
    });
    
    # explicitly load just jQuery and jQuery-UI
    fallback.ready(['jQuery','jQuery-UI'],function() {
        // Completed
    });
    

    In the implementation, the call to "this.initialize();" would be moved from "load()" to "ready()" and would take as argument the optional array that can now be passed to ready(). If the list has entries in it, only those elements would be loaded. The call to initialize(); run immediately when ready() is called (after the callbacks are setup).

    require.js supports basically the same feature with the same syntax, and I assume it's implemented in a similar way.

    Without this feature, I could end up with a proliferation of files related to fallback.js, that each load different combinations of modules. Or more likely, I might consider switchng to using require.js rather than deal with the lack of missing feature.

    Thanks for your consideration.

    Mark
    
    opened by markstos 5
  • resources are fetched twice from the same URL instead of once

    resources are fetched twice from the same URL instead of once

    I watched the related network activity of example.html using Chrome inspector.

    I was surprised to see that it loads jQuery from the Google CDN twice instead once (not counting the intentional initial failure to a different URL).

    The first request returns 200, the next 304 Not Modified.

    jQuery-UI is also fetched twice from the same URL instead of once.

    This appears to be a bug.

    opened by markstos 5
  • Edge isn't loading CSS fallbacks correctly

    Edge isn't loading CSS fallbacks correctly

    Edge isn't loading CSS fallbacks correctly. This is a bug which got introduced in v1.1.6.

    In line 502 to 505, instead of:

    // Needed for IE11 especially. `onload` is fired even when there's a 404 for `link` elements.
    if (type !== 'js' && !me.css.check(library) && Object.hasOwnProperty.call(window, "ActiveXObject") && !window.ActiveXObject) {
        return me.spawn.failed(payload);
    }
    

    It should be:

    if (type !== 'js' && !me.css.check(library)) {
        var isIE = /*@cc_on!@*/false || !!document.documentMode;
        if (!isIE)
            return me.spawn.failed(payload);
        // Needed for IE11 especially. `onload` is fired even when there's a 404 for `link` elements.
        else if (Object.hasOwnProperty.call(window, "ActiveXObject") && !window.ActiveXObject)
            return me.spawn.failed(payload);
    }
    
    opened by jansende 0
  • How to prevent twice loading for scripts that doesn't add a window alias like bluebird.js?

    How to prevent twice loading for scripts that doesn't add a window alias like bluebird.js?

    Hello there, I'm trying to use fallback.js to load bluebird.js, but since bluebird doesn't add any window alias, how am I supposed to prevent twice loading?

    Below is an example of how I've achieved this, but it's a hack so I'm trying to find a correct way to do this.

    <script src="{% static 'assets/js/fallback.min.js' %}"></script>
    <script>
    fallback.load({
        'Vue': [
            '//cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js',
            '{% static "assets/js/vue.min.js" %}'
        ],
        'VueResource': [
            '//cdn.jsdelivr.net/npm/[email protected]/dist/vue-resource.min.js',
            '{% static "assets/js/vue-resource.min.js" %}'
        ],
        'Cookies': [
            '//cdn.jsdelivr.net/npm/[email protected]/src/js.cookie.min.js',
            '{% static "assets/js/js.cookie.min.js" %}'
        ],
        'Object.hasOwnProperty.call((new Promise(function() {})), "_promise0")': [
            '//cdn.jsdelivr.net/npm/[email protected]/js/browser/bluebird.min.js',
            '{% static "assets/js/bluebird.min.js" %}'
        ],
    }, {
        shim: {}
    });
    </script>
    
    opened by bernardoduarte 0
  • added timeout function

    added timeout function

    added timeout function

    If a requested script cannot be loaded successfully within timeout span, fallback automatically tries to load from the next fallback url (without interrupting the original download). First successful download for each library wins.

    Use case for this is a slow responding network, in my case a proxy server which took 60s to return the error code, thus taking my page (with a couple of included scripts and fallback scripts) more than four minutes to load! Now with timeout function it is down to less than 20 seconds.

    Currently timeout is set to five seconds. For v2 of fallback this parameter could be made configurable.

    opened by moving-bits 2
  • DOMException: Failed to read the 'cssRules' property from 'CSSStyleSheet'

    DOMException: Failed to read the 'cssRules' property from 'CSSStyleSheet'

    As of the recent changes from chrome https://chromium.googlesource.com/chromium/src/+/a4ebe08c91e29140e700c7bae9b94f27a786d1ca (more detail information: https://stackoverflow.com/questions/48753691/cannot-access-cssrules-from-local-css-file-in-chrome-64/49160760#49160760) so even the css is loaded from cdn, the check of css exports always failed. an "origin-clean" (see https://www.w3.org/TR/cssom-1/#concept-css-style-sheet-origin-clean-flag) attribute should be added to the element to make the check works on latest Chrome browser.

    opened by cbfrank 0
  • Files are being loaded twice

    Files are being loaded twice

    Hi As I used the library as explained but my files are being loaded twice, here is the code: fallback.load({ BSCSS:['https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css', 'assets/css/bootstrap.min.css'], jQuery: [ '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', '//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js', '/assets/js/jquery.min.js'], BSJS:['https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', //'assets/js/bootstrap337/bootstrap.min.js'], 'jQuery.ui': [ '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', '/assets/js/jquery-ui.min.js'], page_css: ['/subsites/oxtedgasholder/assets/css/main.css?v=1.85'], 'jQuery.validate':['/assets/js/jquery.validate.min.js'], formValidation:'/assets/js/planningsites/formValidation.js?v=1.85', sitejs: ['/subsites/oxtedgasholder/assets/js/site.js?v=1.85'], }, { // Shim jQuery UI so that it will only load after jQuery has completed! shim: { 'BSJS': ['jQuery'], 'jQuery.ui': ['jQuery'], jQuery.validate': ['jQuery'], 'formValidation':['jQuery'], 'sitejs': 'formValidation' },

    	callback: function(success, failed) {
    		// success - object containing all libraries that loaded successfully.
    		// failed - object containing all libraries that failed to load.
    						
    		// All of my libraries have finished loading!
    		// Execute my code that applies to all of my libraries here!
    						
    		}
    });
    			
    fallback.ready(['jQuery'], function() {
    	// jQuery Finished Loading
    					
    	// Execute my jQuery dependent code here!
    });
    			
    fallback.ready(function() {
    	// All of my libraries have finished loading!
    			
    	// Execute my code that applies to all of my libraries here!
    });
    

    HERE is the output copied from browser network tab image Please let me know, if I am doing anything wrong. Thanks in advance. Philip

    opened by pbedi 3
Releases(v1.1.9)
  • v1.1.9(May 30, 2018)

    Added ability to specify integrity and crossorigin properties on CSS and JS resources. Contributors @Blackbaud-PaulCrowder

    README.md cleanup. Contributors @anirvan

    Add matchdep in development dependency. Contributors @199911

    Source code(tar.gz)
    Source code(zip)
Dynamically-loading WebComponent Assembly UI Framework

Golgi: Dynamically-loading WebComponent Assembly Framework Rob Tweed [email protected] 14 February 2022, M/Gateway Developments Ltd http://www.mgate

null 28 Dec 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Fast and lightweight dependency-free vanilla JavaScript polyfill for native lazy loading / the awesome loading='lazy'-attribute.

loading="lazy" attribute polyfill Fast and lightweight vanilla JavaScript polyfill for native lazy loading, meaning the behaviour to load elements rig

Maximilian Franzke 571 Dec 30, 2022
A web app build with HTML, CSS, and JavaScript. It allow users to add a book title and and it's author. Content are rendered also dynamically.

Awesome books: with ES6 Description the project. Built With Major languages Frameworks Technologies used Awesome Books In this project the featured se

Evans Kupour 9 Nov 4, 2022
Fallback for SVG images by automatically creating PNG versions on-the-fly

SVGMagic - Cross browser SVG This repository is no longer actively mainted. It has proven to be very usefull back in 2013, but these days SVGs are sup

Dirk Groenen 596 Jul 27, 2022
Extension forcing Reddit videos to be played by the fallback player.

⚡ FRP: The "Fuck Reddit Player" extension Simple extension to force Reddit videos to be played by the fallback player. Installation: ?? addons.mozilla

Akiyue 9 Oct 21, 2022
Extension forcing Reddit videos to be played by the fallback player.

⚡ FRP: The "Fuck Reddit Player" extension Simple extension to force Reddit videos to be played by the fallback player. Installation: ?? addons.mozilla

あずみ 9 Oct 21, 2022
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.

Introduction Swagger UI allows anyone — be it your development team or your end consumers — to visualize and interact with the API’s resources without

Swagger 23.2k Dec 28, 2022
A weather dashboard that features dynamically updated HTML and CSS using OpenWeather API data.

Weather Dashboard A weather dashboard that features dynamically updated HTML and CSS using OpenWeather API data. User Story AS A traveler I WANT to se

Benjamin Eidum 1 Apr 19, 2022
This project will be a basic website that allows users to add/remove books from a list. The main objective is to understand how to use JavaScript objects and arrays and dynamically modify the DOM and add basic events.

Awesome-books Awesome Books This project will be a basic website that allows users to add/remove books from a list. This project is part of the Microv

Aleksandra Ujvari 10 Oct 3, 2022
Lightweight library service that can dynamically make periodic updates to an Instagram profile.

instagram-dynamic-profile library This library uses the instagram-private-api to automate dynamic updates to an Instagram profile such as cycling thro

null 1 Sep 21, 2022
Basic website that allows users to add/remove books from a list. Achieved using JavaScript objects and arrays, dynamically modifying the DOM and adding basic events.

Awesome Books Basic website that allows users to add/remove books from a list. Achieved using JavaScript objects and arrays, dynamically modifying the

Didier Peran Ganthier 6 Dec 20, 2022
This is a basic app that allows user add/remove books from a list of books. It was created by using JavaScript arrays and objects to dynamically modify the DOM.

Awesome-Books This application lets you compile a dynamic collection of books using JavaScript. It is a single page app. You enter your book title & a

Jules Edozie 7 Oct 24, 2022
JavaScript library for parsing Dirtywave M8 files, complete with a CLI for interacting with M8 files.

m8-js This repository contains a JavaScript library for parsing Dirtywave M8 files, as well as a CLI for interacting with M8 files. The hopes are not

Jeremy Whitlock 20 Dec 17, 2022
Fnon is a client-side JavaScript library for models, loading indicators, notifications, and alerts which makes your web projects much better.

???????? Fnon is the name of my late mother, It's an Arabic word which means Art, I created this library in honor of her name. Fnon is a client-side J

Adel N Al-Awdy 5 Sep 11, 2022
Simple and flexible, css only, content placeholder loading animation.

Placeholder loading Simple and flexible, css only, content placeholder loading animation. Demo https://zalog.github.io/placeholder-loading/ Take a loo

Catalin Zalog 1.4k Dec 30, 2022