Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been using this code for quite some time, but am wondering if there's any improvements I can make to it. Basically it's just code that runs when the page loads or if the code is run after page load, it will run right away. Do you see any cross browser compatibility issues or any more efficient ways of writing this? ol() is a predefined function to be run.

(document.readyState=='complete') ?
share|improve this question

migrated from Feb 26 '13 at 3:56

This question came from our discussion, support, and feature requests site for peer programmer code reviews.

I suggest you take a look at jQuery's implementation of .ready() – Joseph the Dreamer Feb 26 '13 at 8:28
There's some good coverage in Paul Irish's .ready coverage starts around 21:20. There's also some links to jQuery sources. – Michael Paulukonis Feb 26 '13 at 15:47

Just for dealing with ready alone I use jQuery -- it does the cross-browser heavy lifting, is well-tested and maintained. Minified, it's only 32K, and included from a CDN, you get fast delivery that may already be cached in your user's browser.

And there is a lot more code than what you have above to deal with all of the browsers being ready.

There's some good coverage in Paul Irish's 10 Things I learned from the jQuery source screen-case .ready coverage starts around 21:20. There's also some links to jQuery sources.

share|improve this answer
using jQuery only for the ready event is to heavy.. – Wouter J Feb 26 '13 at 16:02
If you're not using a CDN, quite possibly. 32K is HUUUUGE. On my 300 baud modem it takes nearly a minute and a half to download. But the code above is nowhere near heavy enough. extract what you need from JQ, and credit it. I'd be surprised if you don't have other uses for it. – Michael Paulukonis Feb 26 '13 at 16:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.