Eliminate render-blocking JavaScript and CSS

前端 未结 2 655
清歌不尽
清歌不尽 2021-01-12 22:09

I am having a trouble with figuring out what \"this spsefic outcome\" in Google PageSpeed Test actually mean.

I am testing this website: www.loaistudio.com - https:

相关标签:
2条回答
  • 2021-01-12 22:16

    Alternately, just add the async at the end of your script tag.

    <script src='' async></script>
    
    0 讨论(0)
  • 2021-01-12 22:23

    Your browser freezes page rendering while loading JavaScript

    Quick answer: you just have to put your JavaScript src below your content.

    Why? Because when your browser begins loading JavaScript, it freezes the rest until it's done with that.

    Loading the content of your page first allows it to be displayed, and then JavaScript has all the time it needs to load.

    So do like this:

    <html>
        <head>
        </head>
        <body>
            My great body content!
            <script type="text/javascript" src="my/js/files.js">
            <script type="text/javascript" src="http://www.googleapi.com/my/external/scripts.js">
        </body>
    </html>
    

    Instead of this (which is unfortunately still really common):

    <html>
        <head>
            <script type="text/javascript" src="my/js/files.js">
            <script type="text/javascript" src="http://www.googleapi.com/my/external/scripts.js">
        </head>
        <body>
            My great body content!
        </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题