Created
November 3, 2013 21:10
-
-
Save WebReflection/7294841 to your computer and use it in GitHub Desktop.
simplifies ready behavior with modern browsers
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
| /*! (C) Andrea Giammarchi */ | |
| (function(window, add, dom, load){ | |
| function ready(collection) { | |
| return function(e) { | |
| while(collection.length) { | |
| collection.shift().call(window, e); | |
| } | |
| collection.K = true; | |
| }; | |
| } | |
| function on(collection) { | |
| return function(fn){ | |
| collection.K ? | |
| fn.call(window) : | |
| collection.push(fn) | |
| ; | |
| } | |
| } | |
| window.onDOM = on(dom); | |
| window.onLoad = on(load); | |
| document[add]('DOMContentLoaded', ready(dom)); | |
| window[add]('load', ready(load)); | |
| }(this, 'addEventListener', [], [])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment