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
This tests the performance of native window.matchMedia against matchMedia.js and Media.match.
Test whether a CSS media type or media query applies. See http://github.com/paulirish/matchMedia.js
Testing css media queries in Javascript. Not a polyfill and perhaps faster than native window.matchMedia. See http://github.com/weblinc/media-match
<script src="https://raw.github.com/weblinc/media-match/master/media.js"></script>
window.matchMediaPolyfill = (function( doc, undefined ) {
"use strict";
var bool,
docElem = doc.documentElement,
refNode = docElem.firstElementChild || docElem.firstChild,
// fakeBody required for <FF4 when executed in <head>
fakeBody = doc.createElement( "body" ),
div = doc.createElement( "div" );
div.id = "mq-test-1";
div.style.cssText = "position:absolute;top:-100em";
fakeBody.style.background = "none";
fakeBody.appendChild(div);
return function(q){
div.innerHTML = "­<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
docElem.insertBefore( fakeBody, refNode );
bool = div.offsetWidth === 42;
docElem.removeChild( fakeBody );
return {
matches: bool,
media: q
};
};
}( document ));
if (window.removeEventListener) {
window.removeEventListener('resize', Media.watch);
window.removeEventListener('orientationchange', Media.watch);
} else if (window.detachEvent) {
window.detachEvent('onresize', Media.watch);
window.detachEvent('onorientationchange', Media.watch);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
native matchMedia |
| ready |
Media.match |
| ready |
polyfill paulirish/scottjehl/matchMedia.js |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.