Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start jquery script after whole page has loaded?

Tags:

jquery

How do I prevent my jQuery script from running until the whole page is loaded? (Including images .. ).

Thanks!

like image 443
Sven Klouem Avatar asked Dec 22 '22 22:12

Sven Klouem


1 Answers

Instead of $(document).ready(/* ... */); you can use:

$(window).load(
    function() {

});

Or you could just put a script block at the bottom of the page, so by the time the scripts are reached the rest of the DOM's loaded already.

like image 116
David Thomas Avatar answered Jan 06 '23 01:01

David Thomas