Caching page data
JavaScript performance comparison
Info
Spike for storing page meta data inside an object to limit requests to the DOM to improve performance.
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div class="basket">
</div>
<script>
Benchmark.prototype.setup = function() {
var siteObj = {
page: {
type: 'basket'
}
}
$('body').addClass('.basket');
$body = $('body');
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
DOM request to retrieve data |
|
pending… |
Cached value to retrieve data |
|
pending… |
DOM request to retrieve data (cached) |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments