Jump to content

before the whole document gets ready


Recommended Posts

The first question is: Why? The document does not take very long to load, if you were using the window's onload event then you would have to wait for all the images to load first, but document.ready just waits for the HTML to load before firing.


There is no event prior to the ready state. If you want a script to run immediately after a particular element has loaded, put the script tags the first thing inside that element or if it's an empty element, put the script tags immediately after it.


If your script is in the <head> and does not have any event handlers, it will run immediately, but be warned that that script will not have access to any elements on the page because they have not yet loaded.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...