Prototype class: FastInit()

Thursday, October 19, 2006

The awsome Dean Edwards in "Faster DOM Queries" describes a faster version of the window.onload handler for Mozilla browsers and Internet Explorer. It's an ingenius little hack and offers a real javascript DHTML initialisation boost for those browsers. The explanation of the technique is in the article, basically it allows you to initialise when the browser DOM is loaded and not have to wait for all the other resources to load (like images). Here's a neat little class for Prototype I knocked up . This class implements a kind of onload function queue. This will ensure that your initialisation function(s) are called once the browser DOM is ready and not have to wait for all the images. Hopefully easing that bugbear of DHTML interfaces: slow initialisation.


11 Comments

#1
On the July 22, 2006, CountZero wrote:

Great little script. Helps me a lot to initialize all my AJAX functions. thanks a lot! And kudos to Dean!

#2
On the July 25, 2006, Michael Schuerig wrote:

Andrew, for browser detection use either

/WebKit|khtml/i.test(navigator.userAgent)

or

navigator.appVersion.match(/Konqueror|Safari|KHTML/)

The latter is what Prototype uses itself.

#3
On the December 14, 2006, Dummie wrote:

it is nice too, I like your scripts :)

#4
On the January 9, 2007, Paul Sturgess wrote:

Watch out for fastinit, as it will cause the error: 'This Page Contains Both Secure and Non-Secure Items' in Internet Explorer if you are using an ssl certificate.



#5
On the March 10, 2007, sal wrote:

@Paul Sturgess, right I'm running into this same problem as well... and clients aren't to happy with it, any work arounds that you figured out? or anyone?

#6
On the March 10, 2007, Andrew Tetlaw wrote:

It's fixed in the latest version

#7
On the March 10, 2007, Andrew Tetlaw wrote:

http://tetlaw.id.au/view/javascript/fastinit
Latest version can be found here

#8
On the May 27, 2007, eJUNKI3 wrote:

Hello,

i use the K2 Theme for Wordpress and Internet Explorer ans Firefox show the Error that $A in Line 77 not define is. How can i fix this error, can someone give me a hand?

#9
On the May 27, 2007, eJUNKI3 wrote:

Sorry for double post... the latest version of fastinit fixed the problem...

#10
On the November 27, 2008, walter wrote:

demo is not working anymore!

#11
On the September 23, 2009, Jon wrote:

The Demo says that fastinit.js is NOT required for tablesort to work. It appears that this is outdated. I get JS errors when I don't include fastinit.js on a page where I want to use tablesort.js.

Leave your comment


HTML tags will not work. Your email address will never be displayed. If you have a Gravatar we'll display it.

Random outings from a chaotic mind

The Dexagogo Rocket Australian Web Industry Association logo

Delicious

Twitter