I
I
Ivan Bogatov2018-02-11 16:40:58
JavaScript
Ivan Bogatov, 2018-02-11 16:40:58

JS execution after all resources loaded, is there an event?

I noticed that the regular one can run before the site's background is rendered, thereby pausing the rendering itself. And neither placing the script before , nor , nor , nor combinations of these solutions will cancel this behavior. So how do you get the script to run after all the html and css on the site has been executed (specifically, after the entire screen has been rendered)? There is an option with a timer for a second and a non-option with enumeration of everything that should be reloaded before the beginning of the script (because there can be a lot of this abstractly in a vacuum), but there should be a more concise solution to tell JS to wait for the background to be drawn / loading a heavy resource / execution other scripts. alert("Text");</body>window.onload$(document).ready(function(){})

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivanq, 2018-02-11
@Malekith

onload and ready() are exactly what you need. And the fact that alert is called before rendering is a Chrome bug, in all other browsers it is normal, and the bug will only appear with alert.

O
Oleg, 2018-02-11
@politon

Read at least the basics of js https://learn.javascript.ru/external-script

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question