Prototype class: FastInit()
Thursday, October 19, 2006The 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
Great little script. Helps me a lot to initialize all my AJAX functions. thanks a lot! And kudos to Dean!
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.
it is nice too, I like your scripts :)
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.
@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?
It's fixed in the latest version
http://tetlaw.id.au/view/javascript/fastinit
Latest version can be found here
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?
Sorry for double post... the latest version of fastinit fixed the problem...
demo is not working anymore!
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.