raphamorim / nautilus.js

Async CSS/JavaScript loader & dependency manager in ~1kb (600B gziped)
Apache License 2.0
19 stars 2 forks source link

Implement fallback URLs for same script #5

Closed felipemsantana closed 7 years ago

felipemsantana commented 7 years ago

It allows to pass an array of URLs to one script, so it will try in order and if one fails, it will try the next.

Usage:

nautilus.config({
  paths: { 
    jquery: [
      'https://public.cdn.com/libs/jquery.min.js',
      'https://private.cdn.com/libs/jquery.min.js',
      'https://s3.com/libs/jquery.min.js',
      '/libs/jquery.min.js'
    ] 
  }
});
nautilus(['jquery']);

It will try to load the script once in the following order:

  1. https://public.cdn.com/libs/jquery.min.js
  2. https://private.cdn.com/libs/jquery.min.js
  3. https://s3.com/libs/jquery.min.js
  4. /libs/jquery.min.js
raphamorim commented 7 years ago

Amazing @fmatoss, to merge it: Can you add this sample in README?

felipemsantana commented 7 years ago

Done @raphamorim

raphamorim commented 7 years ago

👍