Prototype analog to jQuery’s $(document).ready
I have a lot of experience with jQuery, but less with Prototype. Recently, I needed to add some event handlers to some elements in a Ruby on Rails app I’m building. I searched for how to do the equivalent of jQuery’s $(document).ready() function in Prototype so that I could add the handlers after the document loaded, but most of the guides I found were out of date (I’m running Prototype 1.6.0.3, and I don’t know which version these guides were for, but they all made my Javascript console angry).
Eventually, I was able to piece it together after digging through the depths of the Prototype API documentation. It’s actually very simple:
document.observe('dom:loaded', function(){
// do yo thang...
});
Wrap whatever you’re doing with that, and it won’t be run until the document is loaded.

thanks for you post. I looked for that function some time, it’s really useful.
No problem Igor. I spent a long time looking for it too, glad I could help.
First, this is not entirely the same. If you call jQuery.ready() after the document has loaded, your function will execute immediately. In my tests with prototype, the function was simply never called if the load was already complete.
Second, your site appears to have been hacked. It attempts to redirect to an attack site. If you view source and search for “script” you should see the offending code. Then you get to hunt it down in the template. It will be loads of fun for sure.
Wow, thanks a bunch for the heads up. Looks like it was somehow injected into the bottom of every post. This is going to be awesome! Either way though, thanks for the info on the differences between the two functions.