18

Does anyone know of a good javascript DOM ready library that I can use without loading an entire framework? I found one on google code that seems to work, but the library was posted in 2008 and I can't find any confirmation on up-to-date cross browser support.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
Brian
  • 2,107
  • 6
  • 22
  • 40
  • 1
    have you taken a look at http://dean.edwards.name/weblog/2006/06/again/ ? Specifically [this comment](http://dean.edwards.name/weblog/2006/06/again/#comment367184). Its not plug'n'play ready...but it shouldn't be too hard to set up. – David Murdoch Apr 28 '10 at 18:33
  • 1
    I'd have to ask why is the only thing - jQuery is 19k zipped, and loaded once, used by millions of people on a daily basis so you know it has to work. – cgp Apr 28 '10 at 18:55
  • Im with altcognito, look into jQuery is your best bet – Pablo Apr 28 '10 at 19:22

6 Answers6

9

David Mark's "My Library" has a "DOM ready" functionality:

http://www.cinsoft.net/mylib.html

David is avid anti-framework, anti-bad-javascript-practice so it should be good quality code.

RoToRa
  • 37,635
  • 12
  • 69
  • 105
2

Just do this right before the closing body tag:

<html>
<script>
function runAfterLoad() {
}
... lots of stuff
</script>
<body>

... lots of stuff

<script>runAfterLoad();</script></body>
</html>
Kernel James
  • 3,752
  • 25
  • 32
1

Checkout Dean Edwards' base2. It contains a minimal amount of code necessary to patch up browser differences and provide nice consistent interface as per the standards. The gzipped version is only 6k.

Anurag
  • 140,337
  • 36
  • 221
  • 257
1

Use ded's domready

ryanve
  • 50,076
  • 30
  • 102
  • 137
0

please check out this simple function dom ready function

it has been tested in ie 8 , firefox, chrome and safari .

and check this answer javascript domready?

Community
  • 1
  • 1
Yehia
  • 386
  • 2
  • 9
0

It seems that the safest bet is indeed to use a javascript framework. I was able to find some small DOMready libraries - but nothing written recently or claiming to be confirmed working with the most current browser releases.

Brian
  • 2,107
  • 6
  • 22
  • 40