AndyPiersMorris

Q: Does anyone know how to Eliminate render-blocking JavaScript and CSS in above-the-fold content

Does anyone know how to Eliminate render-blocking JavaScript and CSS in above-the-fold content

Posted on Feb 18, 2015 4:21 AM

Close

Q: Does anyone know how to Eliminate render-blocking JavaScript and CSS in above-the-fold content

  • All replies
  • Helpful answers

  • by Wyodor,

    Wyodor Wyodor Feb 18, 2015 6:46 AM in response to AndyPiersMorris
    Level 6 (19,753 points)
    Feb 18, 2015 6:46 AM in response to AndyPiersMorris

    Read this :

     

    https://developers.google.com/speed/docs/insights/BlockingJS

    Make JavaScript Asynchronous

    By default JavaScript blocks DOM construction and thus delays the time to first render. To prevent JavaScript from blocking the parser we recommend using the HTML async attribute on external scripts. For example:

    <script async src="my.js">

    See Parser Blocking vs. Asynchronous JavaScript to learn more about asynchronous scripts. Note that asynchronous scripts are not guaranteed to execute in specified order and should not use document.write. Scripts that depend on execution order or need to access or modify the DOM or CSSOM of the page may need to be rewritten to account for these constraints.

     

    ------------

     

    To do that in iWeb, open the published webpages and add async to each javascript link at the top of the code :

     

    <script type="text/javascript" async src="Scripts/iWebSite.js"></script>

    <script type="text/javascript" async src="Scripts/Widgets/SharedResources/WidgetCommon.js"></script>

    <script type="text/javascript" async src="Scripts/Widgets/PHPInclude/Paste.js"></script>

    <script type="text/javascript" async src="Scripts/iWebImage.js"></script>

    <script type="text/javascript" async src="Home_files/Home.js"></script>

     

    Most likely you're posting the question in the wrong forum, but with or without iWeb you now know what to do.

  • by AndyPiersMorris,

    AndyPiersMorris AndyPiersMorris Feb 19, 2015 1:50 AM in response to Wyodor
    Level 1 (0 points)
    Feb 19, 2015 1:50 AM in response to Wyodor

    Thank you Wyodor for your super fast response.

     

    I've tried:

     

    Changing the code so that it reads.

     

    <script type="text/javascript" async src="Scripts/iWebSite.js"></script>


    (for example) rather than just


    text/javascript

    in the corresponding scripts

     

    Ive tried adding


    <script type="text/javascript" async src="Scripts/iWebSite.js"></script>


    as a code to the TOP of each corresponding script


    I've tried adding


    <script type="text/javascript" async src="Scripts/iWebSite.js"></script>

     

    <script type="text/javascript" async src="Scripts/Widgets/SharedResources/WidgetCommon.js"></script>

     

    <script type="text/javascript" async src="Scripts/Widgets/PHPInclude/Paste.js"></script>

     

    <script type="text/javascript" async src="Scripts/iWebImage.js"></script>

     

    <script type="text/javascript" async src="Home_files/Home.js"></script>

     

    to the top of all .js  scripts

     

    and to a couple of lines down after the initial page introduction.

     

    in vain I've also tried adding the same as head code and footer code.

     

    But Ive obviously not got it right as yet, as no change from google page speed insights.

     

    If you have time could you please further advise?

     

    Sorry for being a bit of a numpty!

     

    Kinds regards, Andy

  • by AndyPiersMorris,

    AndyPiersMorris AndyPiersMorris Feb 19, 2015 2:17 AM in response to Wyodor
    Level 1 (0 points)
    Feb 19, 2015 2:17 AM in response to Wyodor

    FYI I'm using iWeb to create and iWeb SEOtool to publish

  • by Wyodor,Helpful

    Wyodor Wyodor Feb 19, 2015 3:18 AM in response to AndyPiersMorris
    Level 6 (19,753 points)
    Feb 19, 2015 3:18 AM in response to AndyPiersMorris

    What you want, and what Google describes, cannot be done in iWeb.

     

    So you have to do it after publishing the pages.

     

    iWeb SEOTool has a forum :

     

    http://www.ragesw.com/forums/index.php?/forum/22-seo-software-discussions/

  • by AndyPiersMorris,Helpful

    AndyPiersMorris AndyPiersMorris Feb 19, 2015 4:00 AM in response to Wyodor
    Level 1 (0 points)
    Feb 19, 2015 4:00 AM in response to Wyodor

    Thank you