Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Smallest x-browser DOM Ready, ever

View domready.js
1
function r(f){/in/(document.readyState)?setTimeout(r,9,f):f()}

Doesn't seem to work: http://jsbin.com/ekeba4/ (it acts as window.onload)

@galambalazs,
"window.onload" works on any browser in the planet, this can only emulate "onload" in some browsers and fail with the rest.

It absolutely does not emulate a DOM Ready in any browsers. As an "onload" event alternative is not very performant and:

window.onload = f;

is also much shorter.

@diego - Right, that's what I'm saying, cause the title is "DOM Ready" but this code fails to do that.

Owner
ded commented

yeah. i'm rethinking how this is gonna work now. be back with another implementation

I have recently removed all the UA sniffing I was using in older versions and moved my stable cross-browser solution to GitHub here:

http://github.com/dperini/ContentLoaded

maybe you can have a look at it and compare the outcome. Currently only IFRAMEs do not participate in the optimization. Suggestions are welcome !

Seems to work as described in Safari 5.0.5

Very nice script to my small library.
What is the license?

Owner

use this: https://github.com/ded/domready - it's stable with a license too

sp42 commented

I can not run this function with /in/.test....

this check will fail if the document stays in "interactive" stage. use /in[^t]/ instead of /in/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.