search

Home  >  Q&A  >  body text

javascript - html page loading order problem

<body>
    <button id="btn1">btn1</button>
    <button id="btn2">btn2</button>
    <p>111111111111111111111111</p>
    <p>222222222222222222222222</p>
    <script>
        var a = 0;
        for(var i=0;i<1000000000;i++){
            a++;
        }
       alert('runs1');
    </script>
    <p>3333333333333333333333333</p>
</body>
<script src="1.js"></script> //1.js 中alert(2);


I would like to ask, the rendering of the page needs to wait until the content before the body is parsed, and then the page will be automatically rendered.
Or do I need to wait until 1.js parsing is completed before rendering the page?

过去多啦不再A梦过去多啦不再A梦2736 days ago398

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-05-19 10:47:14

    Look at the browser rendering of this article

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:47:14

    The rendering of the page is top-down, and the page rendering is higher than your 1.js

    reply
    0
  • Cancelreply