I have JavaScript code at the bottom of the page, but images still load after?

I refer to my JavaScript files before closing the body tag, hoping that they will be processed last (since they are not needed until the last). However, when I analyze activity using the PageSpeed ​​parameter in Firebug, the images appear to be the last ones requested.

How to make images more priority than JavaScript code?

+4
source share
3 answers

When you execute your javascript commands in an onLoad event, the images should be read first. After the page is fully loaded, the onLoad-Event is executed.

+2
source

Yes, document.ready is in front of the images. If you want it to start after loading images, you need to use

 $(window).ready(function() {}); 
+2
source

Upload images outside the $ .ready () function

-2
source

Source: https://habr.com/ru/post/1305746/


All Articles