kubetail-org / loadjs

A tiny async loader / dependency manager for modern browsers (899 bytes)
MIT License
2.58k stars 150 forks source link

Announcement: New version with support for Promises and an Edge CSS onerror bugfix #87

Open amorey opened 5 years ago

amorey commented 5 years ago

Hi Everyone,

I just wanted to let you know that we just released a new version of LoadJS (v.3.6.0) that includes a couple of useful features:

First, v3.6.0 adds support for Promises via a returnPromise option:

var prom = loadjs(['/path/to/foo.js', '/path/to/bar.js'], {returnPromise: true});

prom
  .then(function() { /* foo.js & bar.js loaded */ })
  .catch(function(pathsNotLoaded) { /* at least one file didn't load */ });

Second, v3.6.0 includes an important bugfix to detect cross-domain CSS load failures in Edge. Previously, load failures were triggering success callbacks but now they are being handled correctly. The source of the issue was lack of onerror support for cross-domain CSS files loaded via <link rel="stylesheet"> tags. To get around this issue, we are now using rel="preload" to load CSS files in Edge browsers.

Please try out the new features and let me know what you think!

Andres

asos-tomp commented 5 years ago

great news on the promises support!

It's a little fiddly that the output of the loadJs function is now either a promise or not, it would be really handy to have a function akin to:

loadjs.await(...)

...which takes the same arguments as loadJs() and returns a promise, to enable wrapping of both functions independently without needing to coerce in an extra option.