jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Testing four different ways to lazy load content. The basic idea is to allow the inclusion of mark-up in a web page but keep it hidden from the browser parser until some action (e.g. onclick) requires it to be parsed. Takes a hint from Google's JavaScript lazy load library. Ultimately, it's a silly idea.
All are fast. I'm totally confused why the comment code would be so much faster though.
The four methods to store the mark-up are:
<div id="comment-panel"><!-- <img src='rodent.jpg' id='img' /> --></div>
<script type='text/html' id='script-panel-clean-img'><img src='rodent.jpg' id='img' /></script>
<div id="target_1"></div><div id="target_2"></div><div id="target_3"></div><div id="target_4"></div>
<script>
var source_1 = "<img src='rodent.jpg' id='img' />";
var source_2 = document.getElementById("comment-panel");
var source_3 = document.getElementById("script-panel-clean-img");
var target_1 = document.getElementById("target_1");
var target_2 = document.getElementById("target_2");
var target_3 = document.getElementById("target_3");
var target_4 = document.getElementById("target_4");
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Doc Frag |
| ready |
Comment |
| ready |
Script w/ Code Outside Div |
| ready |
Comment Using NodeType |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.