Skip to content

Instantly share code, notes, and snippets.

@mirontoli
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirontoli/dc646ec07467c45d45f0 to your computer and use it in GitHub Desktop.
Save mirontoli/dc646ec07467c45d45f0 to your computer and use it in GitHub Desktop.

Today an interesting conversation arose on Twitter between me and Hugh Wood about _spBodyOnLoadFunctions.push. I tested the _spBodyOnLoadFunctions vs jQuery(document).ready and $(window).load. Here are the results:

  • _jQuery document.ready. Time: 54 default-empty.aspx:495
  • _spBodyOnLoadFunctions. Time: 337 default-empty.aspx:493
  • jQuery window load. Time: 459

alt text

var startedTime = new Date().getTime();
var getMilliSecondsSinceStart = function() {
return new Date().getTime() - startedTime;
}
_spBodyOnLoadFunctions.push(function() { console.log("_spBodyOnLoadFunctions. Time: ", getMilliSecondsSinceStart() ) ; });
jQuery(document).on("ready", function() { console.log("_jQuery document.ready. Time: ", getMilliSecondsSinceStart() ) });
jQuery(window).on("load", function() { console.log("jQuery window load. Time: ", getMilliSecondsSinceStart() ); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment