Last active
May 30, 2016 07:00
-
-
Save lackneets/14e13ff505d3f68a5dba to your computer and use it in GitHub Desktop.
equivalent to $.ready
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
function attachEvent(element, event, fn) { | |
if (element.addEventListener) { | |
element.addEventListener(event, fn, false); | |
} else if (element.attachEvent) { | |
element.attachEvent('on' + event, fn); | |
} | |
} | |
window.ready = window.onReady = function(func) { | |
if (document.readyState == 'complete') { | |
func(); | |
} else { | |
attachEvent(window, 'load', func); | |
} | |
} | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ready(function(){ | |
console.log('Document is loaded!'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment