Optimize CSS Delivery
-
Hi,
I am loading 3 CSS files here: http://www.viatrading.com/wholesale/9/Domestics.html
PageSpeed is telling me I "should fix" the delivery of these CSS Files (see image).
I read https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery , but can't figure out which is my case. The CSS are big, but even if I split them in several, all CSS files are still showing up as render-blocking. I moved them to the header/footer, but the message is still appearing.
Do you know what might be the problem and how to solve it?
Thank you,
-
The concept that Google is trying to setup here is that your CSS and JS contain elements that are critical for the page to render. The problem is that as the browser downloads them, they can block other resources from being downloaded. This is because the browser wants to read these files to see everything they need to download to render the page. Part of fixing render blocking is to reduce the number of files that a browser has to download, especially those in the critical path (html, CSS, JS) that can block the downloading of other files (images, etc)
Google is getting even more specific in your case. They are looking at the "above the fold" parts of your page. What Google wants you to do is take any CSS or JS that you use to render what is "above the fold" on that page and inline that code into your HTML file. That way when the browser downloads the HTML file it has all it needs to render the visible / "above the fold" part of the page vs having to wait for the CSS and/or JS files to download.
The problem is that defining "above the fold" is relative due to the multiple browser size and OS and devices that your web server sees on a regular basis.
If you have a really good front end developer, they can take the time to figure out what viewport size is the most common and then take all the CSS and JS and inline that (and note this may be different depending on the page) into your HTML (and this assumes that your CSS and JS do not bloat your HTML file size too much). One approach is to take your most common large viewport size and then inline all those items into your HTML that are above the fold so you have everything covered as the viewport gets smaller. The issue there (and this is also with most responsive sites) is that you have a lot of code bloat for your phone browsers. You can also use a sniffer to determine what the size of the viewport is and then having the appropriate amount of CS and JS inlined on the fly. I have also seen people suggesting that we should design websites for the phone first and then expand out from there.
This is the best website I have seen that talks about how all these files interact and what Google is really getting at
https://varvy.com/pagespeed/critical-render-path.html
Here is what I would do.
- Have a single CSS file for your site and host it on your server, not an external domain. This is best practice. Take the time to strip out all of the stuff you do not use out of the CSS to get the file size down. Minify and compress it, reference your CSS in your header. This may help with the render blocking as you are reducing the number of files requested to just 1, but it may not help with the above the fold render blocking.
If you want to move forward with with "fixing" the above the fold render blocking. Extract the CSS that is critical to render above the fold items on your site (noting the caveats above) and place it inline within your HTML file and then put the rest in your single CSS file. https://varvy.com/pagespeed/optimize-css-delivery.html
- Have a single JS file and host it on your server. If there is any external JS try and see if you can host it within your single JS file. Strip out all the JS you do not use to get the file size down. Minify and compress it.
If you want to get past the render blocking above the fold item above, figure out what JS is needed to render the page above the fold. Inline that JS within your HTML and then setup a single file for all the other JS and then defer loading of that file using this technique: https://varvy.com/pagespeed/defer-loading-javascript.html
I noticed your external JS file to Googleadservices. You may not be able to put that JS into your main JS file and have to keep the external JS reference. I would then try and defer the loading of that using the technique above. You need to do some testing to make sure that doing this does not throw off how your ads are displayed or tracked. I would also make sure your GA or other web tracking JS code is inlined as well, otherwise you risk throwing off your web stats.
This is what makes all of this tricky. The Google page speed tool is just looking at a list of best practices and seeing if they are present or not. They are not looking to see if your page is actually getting faster or not, or if you change any of these things if they throw off the function of your site.
https://developers.google.com/speed/pagespeed/insights/
PageSpeed Insights analyzes the content of a web page, then generates suggestions to make that page faster
This is why with all of this you need to use a tool that shows actual page speed and will show a waterfall chart with timings to see how everything interacts. webpagetest.org is a common one.
It gets really complicated, really fast, and this is where a a really good front end guy or gal is worth it to look at these things. I would start with my initial simple suggestions above and not sweat the above the fold stuff. Test your site with actual speed and see how it does. You can also setup GA to give you page speed data. You can then decide if you need to take it to the next level.
Another thing you can try (I have not been able to get this to work for me) is that Google has a tool that can do all the "above the fold" inlining and other speed tricks for you
https://developers.google.com/speed/pagespeed/module/
Just like above, I would benchmark your performance and then see if this makes a difference on your site.
Good luck!
-
The main thing this is trying to communicate is that your CSS files should come above / before any Javascript files. When the browser downloads your HTML, it starts at the top and goes down and downloads resources (CSS, JS, fonts, images, etc).
When the browser comes to a JS file, it calls the server to retreive the file, and once it's downloaded, the browser begins to execute that javascript. When that JS is executing, it's delaying the handling of CSS files which help paint the elements and make them look how you want.
Move your CSS files to be above all your JS files and see if that fixes it.
In general, most (not always ALL) JS files should be loaded as the last thing so that it doesn't block / delay the browser in rendering the page.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Do i have to optimize all pages on ecommerce site which is currently 4028 give or take
Hello, do i have to optimize all pages on ecommerce site, as its a lot of pages to developed unique content for my plan at the moment is to start from top down, I have completed top home, featured products etc i have also started on individual team shops my content inst unique to each page more the same and just changing the team name and keyword i was planning on doing that in the blog area of the site and just making the top categories and sub categories. and maybe in time start on the products. I can do all categories in about two months but to complete products would take like 2 years I don't feel that is productive and most would be changed or out of stock by then please take a look at my site and tell me what you think ? sportingdesires.com Kindest Regards, Stephen Kewn
On-Page Optimization | | sportingdesires0 -
Newbie question - Optimize homepage or create new page?
Hey everyone! I'm new here and wondering if anybody could help with a question. I'm trying to optimize for the keyword "meet people". I've attached a screenshot of the Moz SERP report for the top 10 results for this keyword for Google (UK). Unfortunately my domain doesn't make the top ten - we're currently raked 11th. My domain - tastebuds.fm - has a domain authority of 53 and the homepage has a page authority of 61 which is way way above the scores for the 1st placed result. What am I doing wrong? Should I focus on competing using a page that contains the keyword eg. http://tastebuds.fm/meet-people OR should I work on improving the 11th place of my homepage by tweaking the content? Bear in mind I already have an A grade for on-page optimization of the homepage for the keyword in question. If I decided to optimize a new page... how long would it take before I ranked well for the page if the only place it was linked was from the homepage? Also what should I put on this new page? Our homepage already converts well so should I duplicate it somehow? 4ENqCPz.png
On-Page Optimization | | AlexTP0 -
Optimal Copy Length
We have a separate page for every product of every bank e.g. http://www.imoney.my/home-loan/citibank The idea is to make it rank for the name of the keyword + the name of the bank. Is the copy long enough for that to happen? We've written one paragraph of unique copy about bank's product information. Shall we write more, or it is enough?
On-Page Optimization | | imoney0 -
On-page Optimization - Is an A grade absolutely necessary?
It is commonly stated that three exact keyword mentions on a page is best practice for SEO. Recently, however, I have noticed a few articles that have hinted against it. matt @highonseo briefly mentioned the subject here: http://www.seomoz.org/blog/going-beyond-moz-metrics-to-answer-why-is-this-site-outranking-me Also, one our clients competitors is ranking above them with only one exact mention of the keyword in the page title with no exact mentions in page copy. I know other factors can make a difference, but this is does raise questions of our on-site strategy. I haven’t found any literature that specifically recommends using one exact match of a keyword, so any opinion would be very useful! Thanks
On-Page Optimization | | PeteW0 -
Will google see you bold/emphasis words if done in css?
We do not use header tags in our website. I understand bolding or emphsising words can be equally as effective but if done so in css will the google crawlers and spiders etc be able to put a weighted value on this style of code???
On-Page Optimization | | gsbureau0 -
Home Page Optimization For Wordpress Blog
Hi, I'm developing a wordpress site and currently confused over home page optimization. I'm planning to use excerpts of posts on home page so that users can glance over all recent posts and at same time avoid content duplication. But I'm not sure how to optimize the home page for couple of targeted keywords . How can i make sure that there is enough content, proper H1, title tag etc on home page for target keywords even by using excerpts of different posts on home page with Read more links to complete posts? Should i use some sticky post on home page to take care of all onpage requirements for required keywords or there are some other better ways to do it? Regards, shaz
On-Page Optimization | | shaz_lhr0 -
On Page Optimization Reports
How is it determined which terms and associated urls are chosen when SEOmoz tracks your On-Page Report Card? I'm receiving a lot of F Grades for terms I'm not really interested in and a lot of terms I'd like to be tracked aren't. Is there a way I can manually choose which terms and pages I'd like to be shown?
On-Page Optimization | | ClaytonKendall0 -
Can you optimize for 2 keywords per URL?
Or should you just stick to 1 page, 1 keyword all the time? If you do 2, are there any things you should watch out for? Thanks
On-Page Optimization | | inhouseninja0