FastInit: a faster window.onload
This class implements a kind of onload function queue, based on work by the awesome Dean Edwards. 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 web interfaces: slow initialisation.
Current Version: 1.4.1 - 15 Mar 2007 - Demo / Download
Instructions
To use it you need the fastinit.js file and In your page you call FastInit.addOnLoad with a reference or 2 to your onload functions like this:
FastInit.addOnLoad(yourFunction, anotherFunction, yetAnotherFunction); All functions are called in the order in which they were added. You can call addOnLoad as many times as you like. Functions loaded before the DOM is loaded are placed in the queue, and called in order after the 'DOM loaded' event occurs. Those loaded after the DOM is loaded are executed immediately.
It will also default to the standard handlers if the browser doesn't support either of the faster methods.
Demo & Download
Dorky demo, Download here: fastinit.js.
Change Log
Version 1.4.1
- REALLY removed the need for Prototype (what a bone head...)
- Added feature to keep calling loaded functions if they are added after the FastInit.onload event occurs - Thanks Ken Snyder!
Version 1.4
- removed the need for Prototype (and it's even slightly smaller!)
Version 1.3
- fixed bug with HTTPS, thanks Paul for spotting and Rob for the answer
- Code tidy, removed global vars and redundant event listener when not needed
Version 1.2
- Major change - no longer a prototype class, just a singleton.
- Fixed khtml based browser detection - thanks Michael Schuerig
Version 1.11
Released under an MIT-Style license, same as Prototype.
Version 1.1
- New code from Dean Edwards adds support for saffari and removes need for seperate IE file
- Added ability to pass multiple functions on initialisation
- Added addOnLoad function
- Fixed bug for onload handler for non supported browsers
- Fixed bug so onload is only called once
Version 1.0
- Initial version