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
Bulk inserts into the DOM take place through appendChild. By injecting a massive string of HTML to innerHTML we might get better performance. The only shortcoming is that we can no longer directly reference the elements that are injected in this way. The solution is to use ids = $(' *', container) to establish the ids in the DOM.
Here are a few tests that may not all be on a level playing field. This is just to get a feel for the differences.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="testdiv">Test div, should be cleared before a test starts</div>
<script>
function make_test_element(id) {
return "<div id=\"ele" + id + "\" class=\"testdd\"></div>";
};
function pmake_test_element() {
return "<div>";
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
jq (inner)html |
| ready |
jq append |
| ready |
raw innerHTML |
| ready |
raw appendChild |
| ready |
jq (inner)html with identity rebuild |
| ready |
raw appendChild with identity |
| ready |
raw appendChild with removed DOM element |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.