Enquire

jQuery – Start jQuery After Page Has Fully Loaded

jQuery Scripts & Helpful Snippets

If you want your jQuery to start executing after the page is fully loaded, you can use the following code:

1
2
3
4
5
<script type="text/javascript">
jQuery(window).on("load", function () {
// insert code here
});
</script>

I usually use this code for when I want animations http://topessayservice.org/ to start running or images to start fading in/out after the page has loaded, so users don’t miss the effect.

Just want to mention that the above code shouldn’t be confused with the following document ready event:

1
2
3
4
5
<script type="text/javascript">
$(document).ready(function() {
// insert code here
});
</script>

The document ready event executes when the HTML is loaded and the DOM is ready, even if all the images on your page haven’t loaded yet. The window load event executes later when the page is fully loaded, including all images and other objects.

Comments

Leave a reply

Your email address will not be published. Required fields are marked *

X