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.
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
-
Keyword Cannibalization vs. Optimizing Site
I am in the process of optimizing our website and I am having a hard time reconciling two best practices I have found on Moz. 1. You should avoid having multiple pages focus on the same keyword because you will lose some control of which result will show. 2. You should identify your core keywords and weave these keywords multiple times (naturally) throughout your site. I have spent months identifying our top 7 keywords and am working through the site now. The first piece of advice keeps giving me pause. Can anyone weigh in with other considerations or advice on how I can reconcile these two strategies. Thank you
On-Page Optimization | | NikCall2 -
Should I spend time going back and optimizing old blog posts for SEO or just write new posts?
The site I manage (Boutique Estate Law Firm) has at least 350 old blog post archived that were not well optimized for SEO. Would it be valuable to go through and optimize those old posts or just write new optimized posts even though they are on the same subjects? My boss loves to churn out 300 word posts.
On-Page Optimization | | SEO4leagalPA0 -
SEO optimization for popular long-tail content
I was wondering if you all have tips / best practices to SEO-optimize new pages created for popular long-tail queries, as well as recommendations to assure we don't have duplicate content issues.
On-Page Optimization | | CuriosityMedia0 -
Best SEO extension or plugin for on-page optimization
I was wondering what you guys might recommend for a browser extension or plugin that would help developers optimize each page for specific keywords. I'm looking for a tool that will give me a grade on how well it's optimized with a recommendation checklist. I would use SEOMoz's onpage analysis tool but it doesn't have access to my private development environment (hence the need for a plugin.) Recommendations? Thanks!
On-Page Optimization | | net32SEO0 -
Optimize Page Title - Advice
I am currently going through my site and re-doing the page titles to try and optimize each specific product's page. I know that having the part number as the first piece of text in the title is the best practice. My question is, if i add a bunch of terms to the title, after the part number, is that taking away from the important part (the product number)? For example, my product is Audi A4. The term i want to optimize for is Audi A4. Which would be the better title for ranking purposes? A) Audi A4 | Automobile or B) Audi A4 | Automobile | 4 Cylinder | Made in Germany Thanks for the advice!
On-Page Optimization | | Prime851 -
Finished On Page optimization and slipping in rankings
Just finished on page optimization for a client that was on page 2 for the keyword. Went from an on page score of D to an A. But we are still slipping down the rankings. We were towards to top of page 2 now we are towards the bottom. Is there a time that it takes to change or does the on page not really make a big impact?
On-Page Optimization | | devonkrusich0 -
Image Optimization - File Name Important?
I am currently working on a site with 100+ recipes that all have image file names that are relevant, but not optimized for keyword purposes. I'm wondering - from an SEO perspective - would it be worth my time to go back through all of the images and rename them with keywords in mind? On my own site I have always done this as a "best practice" but I'm curious - does it make a difference to search engines? Does anyone have any recent research/experiences that they would like to share? Thanks!
On-Page Optimization | | EssEEmily0 -
Optimization of home page
Hi there I have an issue which, despite searching hard, I simply cannot find the right solution for. We have an index page that used to rank pretty well for a main industry keyword. However following a revamp of the site last year the kw slipped and no longer brings in decent traffic levels. The problem seems to be that the old static site had a sprinkling of variable anchor text links that brought value to the home page. Instead of the main anchor being "home" we would revert to "main keyword" and variations across the site sometimes in t he content but mainly on the nav bars. However the new CMS design structure restricts us considerably with anchor distribution and so instead we opted for the site logo on the masthead to have an ALT tag for "main keyword" but so as not to game google too much we added .."home" to the tag. Probably pointless but we figured it could do no harm. This ALT text is site wide Problem now is that we have lost the spread of internal nav bar anchors and variety etc. We have slipped in the serps for "main keyword" and I cant help thinking we are not maximising the anchors as we should. So what Im coming to is this.... How can we tell if Google is picking up the ALT tage anchor as the main anchor to rank the site at the expense of all internal text anchors. Despite retaining lots of embedded anchors - according to the Moz metrics these are not being picked up because OSE suggests the ALT tag anchor is taking precedence. The serps probably support this view as well. Should we: a) Vary the masthead ALT if there is no way of avoiding this being the most important link / anchor on the page b) Remove the ALT anchor and instead opt for content links high on the page (we do have nav bar links saying "Home" site wide as well which may overrid the embedded links?) c) Leave the ALT alone and still push for content anchors as described in b) What is the best way to handle this..? Best wishes and thanks Morch
On-Page Optimization | | Morch0