Wednesday, July 30th, 2008

onJSReady Prototype Plug-in

Category: JavaScript, Prototype

In a follow-up to our post a few days ago on parallelizing JavaScript loading and firing an event when loading is done, Stefan Hayden wrote a Prototype extension (based on onDOMReady) that makes it easy for you to execute your code when all JavaScript is loaded:


  1. Event.onJSReady(function () { dependent_on_external_js(); });

Posted by Ben Galbraith at 9:30 am

4.1 rating from 27 votes


Comments feed TrackBack URI

I dig Stefan’s script, but it pollutes the global namespace/Event object a bit. An alternative would be:

document.observe(‘scripts:loaded’, function() {…});


Comment by jdalton — July 30, 2008

Another benefit of jdalton’s version is that it fires custom events the Prototype Way™, rather than relying on an obscure method on Event.

Comment by eyelidlessness — July 30, 2008

I’m loving jdalton’s update. I’m definitely going to try that out. Cheers!

Comment by STHayden — July 30, 2008

Leave a comment

You must be logged in to post a comment.