onload vs DOMContentLoaded (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<script>
  var fn = function() {console.log(2*2)};
  function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
load event
window.addEventListener('load', fn);
ready
onload
window.onload = fn;
ready
ready
r(fn);
ready
DOMContentLoaded
document.addEventListener('DOMContentLoaded',fn);
ready
jQuery $(document).ready()
$(document).ready(fn);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.