Skip to content

Instantly share code, notes, and snippets.

@adamghill
Last active November 20, 2017 20:43
Show Gist options
  • Save adamghill/327ba95b9d927b203ac78aa2bd656a0d to your computer and use it in GitHub Desktop.
Save adamghill/327ba95b9d927b203ac78aa2bd656a0d to your computer and use it in GitHub Desktop.
jquery-lite
window.$w8 = window.$w8 || function (fn) {
if (document.readyState === 'complete' || document.readyState !== 'loading') {
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
};
window.$gme = window.$gme || document.querySelector.bind(document);
window.$$gme = window.$$gme || document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
};
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = NodeList.prototype.addEventListener = function (name, fn) {
this.forEach(function (elem, i) {
elem.on(name, fn);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment