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
Like most browser scripting operations, setting an element’s STYLE
attribute may or may not be needed (most apps not). Of course, most libraries attempt to clear that hurdle in one way or another. You get the extra code (and overhead) whether it is beneficial or not. A lot of libraries (as well as old copies of others) use UA-based browser sniffing to “fix” issues with IE5/6/7/compat mode.
<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 all tests
var elHtml = document.documentElement;
var css = 'color:black;background-color:white';
// For My Library test
var setAttribute = API.setAttribute;
// For cross-browser test
// Remove else case to degrade in IE under 8
// First branch weeds out bad IE browsers (and other older browsers)
// For completeness, should probably do a try-catch on a set as well
// Can check that styles take in properties and (in some cases) in layout
if (elHtml) { // Need this for detection, could also create element
if (elHtml.setAttribute && elHtml.getAttribute && typeof elHtml.getAttribute('style') == 'string') {
var setStyleAttribute = function(el, css) {
el.setAttribute('style', css);
};
} else if (elHtml.style && typeof elHtml.style.cssText == 'string') {
var setStyleAttribute = function(el, css) {
el.style.cssText = css;
};
}
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
My Library |
| ready |
jQuery |
| ready |
Cross-browser |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.