Reputation: 706
I'm trying to speed up my website by applying google PageSpeed Insights recommendations, but some things don't make sense to me.
Results that I get: https://goo.gl/GSQ6Zs
It says that above the fold content couldn't be loaded without a delay because of jQuery, my jQuery script reference is placed before closing body tag, what is really interesting is that if I copy/paste source code from jQuery file and put it directly into index.html as inline code it works perfectly, but this solution looks dirty to me. What are fast ways to determine what javascript/css files are responsible for displaying above the fold content? I also have many css files and it's really inconvenient to go through every file and determine which parts are responsible.
Any suggestions are welcome
Upvotes: 3
Views: 8078
Reputation: 3358
First step will be to move google fonts link on top of <link rel="stylesheet" href="/components/com_rsform/assets/calendar/calendar.css" type="text/css">
so that the font request is sent at the earliest, and make a single request instead of three:
<link href="http://fonts.googleapis.com/css?family=Droid+Serif:400,400italic|Droid+Serif:400,400italic|Tangerine" rel="stylesheet" type="text/css">
Then minify all your js(JS Minifier), css(CSS-Minifier) to reduce bytes. Start caching in js files which are mentioned in google page speed test.
Add defer attribute on inline script tags which you think can be executed after everything has loaded on page. for example:
<script defer>
//your code
</script>
Upvotes: 2
Reputation: 2869
First read the two articles:
https://developers.google.com/speed/docs/insights/BlockingJS https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery
The problems you have are with the following files:
You can do a few things to fix this such as Inline JS, using async or in most cases putting your .js
files at the bottom of your script below everything else.
Simply copy the .js from the file into your .html file with <script>
tags around it.
I wouldn't suggest this if you're loading jquery as it may try to run the jquery code on your page before the script is loaded causing errors.
Although this isn't on the google page, doing this normally fixed your problem although the script still needs to be loaded for the page to fully load. Someone may need to correct me on this.
This pretty much is so that you don't fetch a bunch of separate css files before your page can load.
Copy and pasting the css into your html file seems to fix the issue as it loads as the page loads. Personally I've read that this may cause the page to load a bit slower, but it'll give you a higher pagespeed score.
As stated in the answer here, you'll avoid the pagespeed issues if you add the css through javascript rather than fetching a bunch of css files.
Upvotes: 4