Loader
var Loader = { loaded: false, addOnLoad: function(fn) { if (this.loaded) fn(); else { var oldonload = (window.onload) ? window.onload : function () {}; window.onload = function () { oldonload(); fn(); }; } }, init: function() { this.loaded = true; } }; Loader.addOnLoad(Loader.init);