📜 ⬆️ ⬇️

Practical JS: deferred loading

Note: below is a translation of two consecutive articles “The window.onload Problem - Solved!” And “window.onload (again)” , dedicated to optimizing the execution of scripts when the page is loaded, this problem was previously discussed in the article: “How JavaScript slows down the Web ( and what to do with it)?"

To begin with, we will define the problem itself. The window.onload event is used by programmers to start their web application. It can be something quite simple, for example, a drop-down menu, and maybe quite complicated, as an example, launching an email application. The essence of the problem lies in the fact that the onload triggered only after the entire page is loaded (including all the images and other binary content). If there are a lot of pictures on the page, then you can notice some delay between the page loading and the moment when it starts to actually work. In fact, we only need to find out how to determine when the DOM is fully loaded, and not to wait for the loading of images.

read further on webo.in →

')

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


All Articles