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
Basic DOM operation: setting inner HTML of a DIV element
When context restricts eligible containers to DIV elements, all of the issues (and extra code) fade away. TD's work just fine too. There are reasons that TABLE, TR, etc. don't work in IE. MS invented the innerHTML property and explicitly disallowed TABLE, TR, etc. from using it. There is another API for those. Same for SELECT's.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
/*
* Context here is an HTML5 document
* Appropriate build for this context would exclude XHTML support
* Next line asserts document will create an HTML DOM
* There are virtually no documents on the Web that create an XHTML DOM
*
*/
var API = { disableXmlParseMode:true };
</script>
<script src="//www.cinsoft.net/mylib099-min.js"></script>
<script>
// For My Library test
var setElementHtml = API.setElementHtml;
// For cross-browser test
// Restricted to subset of elements (e.g. DIV's, TD's)
// Degrades in IE3 (not a misprint)
// Replace with more elaborate version when context requires
// NOTE: Use isHostMethod for host method detction
if (document.createElement) {
var elDiv = document.createElement('div');
}
if (elDiv && typeof elDiv.innerHTML == 'string') {
var setHtml = function(el, html) {
el.innerHTML = html; // That was easy :)
};
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
My Library |
| ready |
My Library (OO) |
| ready |
jQuery |
| ready |
Cross-browser |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.