basket.js versus browser cache (v2)

Revision 2 of this benchmark created by Mat Scales on


Description

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

Preparation HTML

<script src="https://addyosmani.github.com/basket.js/dist/basket.js">
</script>

Setup

// 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);
    }

Teardown


    basket.remove("jquery");
    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);
      }
    }
  

Test runner

Ready to run.

Testing in
TestOps/sec
basket.js
// async test
basket.require("jquery").wait(function() {
  deferred.resolve();
});
ready
Browser cache
// async test
var script = document.createElement("script");
script.addEventListener("load", function() {
  deferred.resolve();
});
script.src = url;
document.head.appendChild(script);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.