basket.js versus browser cache

JavaScript performance comparison

Revision 12 of this test case created

Info

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

Preparation code

<script src="//addyosmani.github.com/basket.js/dist/basket.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    // Warm the cache
    // A random URL from a CORS enabled data source
    var url = "http://www.wibbly.org.uk/jquery.js";
   
    // This can be synchronous for testing purposes
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url, false);
    xhr.send();
    if (xhr.status === 200) {
      var now = +new Date();
      // Adding to the localStorage by hand to make sure that it is done
      // synchronously
      localStorage.setItem("basket-jquery", xhr.responseText);
    }
};

Benchmark.prototype.teardown = function() {
    basket.remove("jquery");
};
</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("jquery").wait(function() {
  deferred.resolve();
});
pending…
Browser cache
// async test
xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onreadystatechange = function(xhrEvent) {
  if (xhr.readyState === 4 && xhr.status === 200) {
    deferred.resolve();
  }
};
xhr.send();
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