rgrove / lazyload

:skull: An ancient tiny JS and CSS loader from the days before everyone had written one. Unmaintained.
MIT License
1.39k stars 288 forks source link

Add a .both() method to load CSS and JS in parallel, with a single callback #3

Closed rgrove closed 13 years ago

rgrove commented 13 years ago

Could just be a wrapper around calls to .js() and .css(). Something like this:

function both(cssURLs, jsURLs, callback) {
  var cssDone, jsDone;

  function finish() {
    if (cssDone && jsDone) {
      callback();
    }
  }

  LazyLoad.css(cssURLs, function () { cssDone = 1; finish(); });
  LazyLoad.js(jsURLs, function () { jsDone = 1; finish(); });
}