Google Chrome loads the javascript first even I put the script tag before the end of the body tag

后端 未结 5 1218
刺人心
刺人心 2021-02-11 06:19


I have a problem with loading JavaScript in Google Chrome.
I\'ve created the separate js file with a simple alert message and then linked it before the end of the body

5条回答
  •  面向向阳花
    2021-02-11 06:19

    async and defer boolean attributes are only helpful when the script is inserted in the head portion of the page. They are useless if you put the script in the body footer like we saw above.

    (Refer following article: https://flaviocopes.com/javascript-async-defer/).

    I am also facing similar issue and using window.onload = funcRef; with cleared cache also does not work on my google chrome. I have tried all of this with disabling all my browser extensions but in vain.

    I was finally able to, not solve, but agree upon a way around - which was - to include a

    jQuery CDN

    before my javascript script in the body. Hope this helps.

提交回复
热议问题