Is it practically good to put JS files at the bottom of webpage?

前端 未结 7 1475
情歌与酒
情歌与酒 2020-12-18 03:26

It is widely recommended that JS files should be put at the bottom of page to allow html codes to be loaded first. In this case, visitors will see something when waiting for

7条回答
  •  被撕碎了的回忆
    2020-12-18 03:47

    I have occasionally recommended putting Javascript at the bottom of a page (just before ) but only in circumstances where a novice programmer couldn't really cope with window.onload or and that was the easiest adaptation of their code to get it to work.

    I agree with your practical disadvantages, which need to be balanced against Michael's note of the effect on load time. In most cases [I submit] loading scripts in the of the page wins.

提交回复
热议问题