Window.onload() is a workhorse of traditional javascript code. It’s been used by coders for years to kick start the client side magic as soon as everything on the page loads up.

But sometimes waiting for a page to load just isn’t quick enough.

A few large image files will quickly reveal that window.onload() can be painfully slow. So when I was creating a web app for internet marketers recently, I had to have something faster.

Some quick research into possible workarounds for the window.onload() issue brought me to some code by Brother Cake. If all you need is a fast way to kick start your javascript then their code might be something to try.

But if you’re going to be doing some DOM (Document Object Model) javascript coding then why not use jQuery and have your cake and eat it too (horrible pun – sorry).

jQuery has a handy little function that launches your javascript as soon as the Document Object Model is ready… which happens before the page has finished loading.

$(document).ready(function(){
  // Your code here...
});

You can use it to launch any kind of javascript you like. It doesn’t have to be reserved for jQuery style coding. And there’s nothing wrong with telling jQuery to launch several different functions at once.

Similar to many init() functions you may have seen before… just a lot faster.

You’ll see this code used again and again in the examples I give you on 15 Days of jQuery.

[tags]jQuery, DOM, javascript, window.onload[/tags]