Skip to content

Instantly share code, notes, and snippets.

@DJTB
Forked from WebReflection/document.ready.js
Last active August 29, 2015 14:27
Show Gist options
  • Save DJTB/3ff4b54384c16cb2fecc to your computer and use it in GitHub Desktop.
Save DJTB/3ff4b54384c16cb2fecc to your computer and use it in GitHub Desktop.
Inspired by jQuery, an inline function to solve forever any problem related to DOMContentLoaded (with or without defer)
!function(r,e,a,d,y){function $(f){d?f():r.push(f)}e.ready=$;e.addEventListener(a,y=function(){d=!e.removeEventListener(a,y,d);while(y=r.shift())y()},d)}([],document,'DOMContentLoaded',!1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment