javascript Document ready firefox (jQuery)

Ian Vink picture Ian Vink · Dec 6, 2009 · Viewed 10.4k times · Source

In FireFox I have this jQuery at the end of the body:

$(document).ready(function() {
     $.getScript('LiveMapsJavascriptProvider.aspx?type=reference&value=6', init);
});

There are a lot of js files in the head that are needed to be all loaded before this would work. So I put my call in a document.ready event. It doesn't work. IE works fine.

If I put an alert(''); before I call $.getScript it works.

It looks like a problem with the scripts not getting loaded yet?

I thought Document.ready was fired after all the scripts are loaded and ready to go.

Thanks, ian

Answer

Darin Dimitrov picture Darin Dimitrov · Dec 6, 2009

document.ready is fired after the DOM is loaded. You may try this:

$(window).load(function() {
    // will execute once all scripts and images are finished loading
});