Wednesday, July 30th, 2008

onJSReady Prototype Plug-in

Category: JavaScript, Prototype

<>p>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:

javascript
< view plain text >
  1. Event.onJSReady(function () { dependent_on_external_js(); });

Related Content:

Posted by Ben Galbraith at 9:30 am
3 Comments

++++-
4.1 rating from 27 votes

3 Comments »

Comments feed TrackBack URI

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

usage:
Prototype.include(‘test1.js’,'test2.js’,'test3.js’);
document.observe(‘scripts:loaded’, function() {…});

- JDD

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.