Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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

Reply
5 replies

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.

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

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

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.