basket.js versus browser cache

JavaScript performance comparison

Revision 11 of this test case created

Info

Does using basket.js improve caching performance over the browser cache?

Preparation code

<script src="http://addyosmani.github.io/basket.js/dist/basket.min.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    // Warm the cache
    // A random URL from a CORS enabled data source
    var url = "http://code.jquery.com/jquery.min.js";
   
    basket.require({ url: url, key: "jquery" });
};

Benchmark.prototype.teardown = function() {
    basket.clear();
    var scripts = document.getElementsByTagName("script");
    for (var i = 0; i < scripts.length; i++) {
      var script = scripts[i];
      if (script.defer || script.src === url) {
        script.parentElement.removeChild(script);
      }
    }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
basket.js
// async test
basket.require({ url: url, key: "jquery" }).then(function() {
  deferred.resolve();
});
pending…
Browser cache
// async test
var script = document.createElement("script");
script.addEventListener("load", function() {
  deferred.resolve();
});
script.src = url;
document.head.appendChild(script);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment