Javascript Download Timeout

Consider the following document

<html>
    <body>
        This is some content
        <script type="text/javascript" src="verySlowToRespond.js"></script>
        This is some more content
    </body>
</html>

First, I would like to test my assumption that the browser is unsafe for parsing the tag scriptuntil the script is loaded and executed.

This means that (if my assumption is correct), say verySlowToRespond.jsit takes 20 seconds to respond, the DOM page cannot be fully assembled until this dependency is resolved.

Suppose that verySlowToRespond.jsexists indefinitely? At what point does the browser refuse and continue parsing?

+3
source share
3 answers

: script, .

, . .

, , script. - ? script , , ?

+3

, . , <script> .

. script. .

+2

. script. - , .

If you are concerned about the script loading time, it is important that the script does not make any DOM changes that must be performed before the rest of the page. Then you can add a onloadcall handler to setTimeoutexecute the code to asynchronously load the script.

+1
source

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


All Articles