Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Is Critical Rendering Path the new Source-Ordered Content?

         

ergophobe

5:41 pm on Mar 27, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The dinosaurs will remember when people obsessed about Source-Ordered Content. In fact, it was enough of a concern that you could just say SOC and everyone knew what you meant.

Knocking Your SOCs Off
For those who need a refresher, before CSS when people were building layouts with tables, you had no good option but to put the visual top of your page highest in your code. The search engines were dumb back then and they would commonly crawl only a small amount of your page and would often use the first bit they found as the snippet. If your code was confusing or your navigation was excessive, that was all the crawler saw.

When browser support for CSS reached a critical point, but search engines were still not chunking out repeated content and years from regular rendering with headless browsers, many SEOs used CSS to position the content first in the code and put the page header at the bottom. The idea was to feed the search engine first and foremost what was unique to the page.

Then off course, Google knocked our SOCs off. They introduced content chunking and headless browsers and were followed by other search engines and we all pretty much quit bothering.

Doing CRP When Your Site is in Render Arrest

Now that the patient has had its SOCs knocked off, we went and gave it a very high fat diet - lots of JQuery and Bootstrap and a zillion other things. Next thing we noticed, it was going into rendering arrest. So we have to do CRP, not CPR, to save this patient.

The Critical Rendering Path [developers.google.com] describes which objects have to load before the page can show the above-the-fold content. If you have a blocking resource, it means the whole page has to wait for that resource to load before rendering. This is bad and at least three years ago, Pierre Far was saying at Pubcon that SEOs should be paying more attention to the CRP.

What to do?

It's not nearly so simple as SOC, but unlike the SOC problem, it's also not going away because search engines get smarter. There are things you can do, however.

We are concerned above all with resources that block rendering above the fold. But in this world of many screen sizes, what is above the fold anyway? First priority should be resources above the mobile fold, because mobile users are more likely to be on slow, high-latency connections.

1. Identify those resources. Run Pagespeed Insights or GTMetrix or some other tool that will identify your render-blocking resources.

2. Start fixing the problem.

Fixing the CSS

If you have render-blocking CSS, you can inline it. If you run Pagespeed on your server, it can do this for you on the fly. See
[modpagespeed.com...]

You can also run a tool like CriticalCSS and see what it suggests for inlining. Note that this will lead to some bloat unless you also go through your CSS and remove the rules that you've now inlined.
[jonassebastianohlsson.com...]

Fonts are a common culprit and for that you can use some web font loader like Typekit's Web Font Loader [github.com]

Fixing the Javascript

Easy, right?

There are several Javascript loaders. Some years back I got huge gains on a poorly-designed site with LABjs, taking a 12-second time to first interaction down to a 2-second time to first interaction (that is, when the page was visually present above the fold and ready to interact with, which is not the same as DOM-loaded or fully loaded). These days, I think RequireJS would be the most popular choice. But there are also conditional loaders such as yepnope.js and whole galaxy of tools.

They can help a lot, but some things simply can't be loaded asynch without breaking the site. For the site I mentioned above, I had to hide the main nav (you read that right, display:none on the main nav) until the document.ready event fired and then switch it to display:block after all the critical path components loaded. It made for a dramatically better user experience on first page load, but really it was a Band-Aid on a broken site that had been poorly architectured... and brand new.

Okay, so asynch won't work. Then we run Pagespeed and inline Javascript same as CSS, like so: [modpagespeed.com...]

Done!

Not so fast (so to speak). Do you really want to inline tons of Javascript in such a way that it won't be reused on subsequent page loads. Remember: Reduce, Reuse, Recycle. Reduce comes first if possible.

Reuse/Recycle might include not just caching your files, but for the most popular resources (JQuery, Modernizr), loading them from a CDN to increase the chance they are already cached in the user's browser. Be warned, though, that if they are running an ad blocker or Privacy Badger, your JQuery from a third-party CDN might be blocked.

Add those into the mix with inlining and loading scripts asynchronously as often as possible and you're well along the way.

Your Experiences?

Those are just a few half-baked thoughts thrown out as I type. More nuts and bolts than I had intended. I was really interested on a discussion at a bit higher level but, as is my tendency, got a little down in the weeds. Really, what I'd like to know is.

  • Do you remember the days of SOC?
  • Are you paying attention the CRP?
  • What strategies have been most effective?
  • What are the most common culprits? Which resources make up your Most Unwanted list?

keyplyr

4:26 am on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks for a great post ergophobe.
If you have render-blocking CSS, you can inline it.
In a perfect world :)

I've given a lot of thought and effort to eliminating render-blocking CSS. Every time I run Pagespeed I am reminded. However Pagespeed treats every page as a first-time page load, ignoring caching. The speed hit is only on the 1st page load for the user.

I basically use 1 CSS file (not counting a couple work-arounds for certain browsers.) I have minified that file (Pagespeed is happy with that) and I load it async, but if I broke it up and used inline versions it would significantly slow down most pages (I've tested this.)

So while theoretically sound advice on the inline CSS (and I do use many inline divs) sometimes real world practical use differs.

ergophobe

5:18 am on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There are always tradeoffs.

The win for inlining is if you need only minimal CSS/JS for the above the fold sections and it's more or less the same for each page. Otherwise, managing your CSS will be a nightmare and, as you say, the benefits are low.

It's the same quandry with another technique I mentioned - base64 encoding of resources like images. It saves one round-trip request (or two if a DNS lookup is required), but it adds 10% to the size of the image and of course is not cacheable if it's inlined on the page. You can, however, eliminate requests for really small images if you inline them in your CSS - then it's cacheable, the 10% doesn't hurt much and you drop one request. So it's used more for a background image than, say, a logo.

What other techniques are you using?

not2easy

5:48 am on Mar 28, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



SOC? Oh, yes. I never went so far as to put the header below the footer, merely swapped a sidebar to appear on the left visually while appearing after the main content in the html. I didn't like it and had replaced it by the time SOC was made pointless.

My unfavorites are the near universal use (or at least very widespread) of bootstrap and other 'default' offsite resources, the multiple external calls for scripts and unnecessarily huge css files that are used in WP themes. You could say code bloat tops my Unwanted list.

tangor

6:13 am on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



K.I.S.S. still rules ... but in today's "interactive all dancing jiggly world" the lines do blur a bit. I tend to do reduce more than anything. Little to NO js, no third party, no reliance on font serving, as few divs as possible and optimized images (where included). If an image is not needed I don't use one. And if a table works for a data display, that's the format used. :)

Mobile has re-introduced two things many of us left behind: bloat and screen (viewport) size. When desktop speeds are rising, we have limitations in mobile ... and mobile is becoming the 600 pound canary as far as visitation is concerned.

For me, the reduce remains the method as less, as far as mobile is concerned (see AMP, etc), is the best hammer for that nail. Only place I am investing time these days is in viewport and serving to that ... again with no third party and as little to NO js as possible.

Aside, where js might be useful I seek a server side (perl) solution as dealing with the growing number of script and ad blockers is a waste of time.

keyplyr

7:34 am on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm guilty of JS reliance bigtime. However, as mentioned above, they are easily & effectively cached by the browser. A very large percentage of my site visitors are repeat & I use a long cache expirary.

But if I was to build another site from scratch, I would use less JS.

ergophobe

4:45 pm on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>>bootstrap

There was a time I really liked Bootstrap and Foundation. To some extent I still do, provided you do a build that only includes the parts you need, which can be fairly light.

The use case that makes sense: you're building a site that is responsive and has overlays, carousels, and all manner of widgets. You get some efficiency by staying within one ecosystem

The use case that happens in the real world: you really want grids and responsive nav, but you add in an extra 300KB of Javascript and CSS because it's the easiest way to use Bootstrap and Foundation.

>>no reliance on font serving

I tend to see that as the lowest ROI. Fonts are typically render-blocking and often the "must have" font has a near equivalent. Typography matters for usability and conversion and, in our current world, that means it matters for Google SEO, but I think the font itself is usually the least of typography. Font size, line length and line height are the big ones.

ergophobe

5:10 pm on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



By the way, though it may be obvious to everyone here, you might ask why this is in Google SEO instead of Accessibility and Usability or Webmaster General.

The SEO component is that when Google goes to render your page in the headless browser, blocking resources on the critical path will be the key thing that determines how slow your site is. As we know, ultra fast speed isn't that important for Google (not talking about users or conversions), it's more a matter of reaching a threshold level. That is you don't get any credit for dropping from 1.3-second loads to 1.1-second loads. But as I mentioned in the example in initial post, handling resources in your critical path properly can take you from 12 seconds to 2 seconds.

Sourced-Ordered Content was primarily a CSS topic (how to) and an Accessibility (screen readers choked on that table madness), but most people were motivated by SEO concerns.

Critical Path Rendering is also a developer topic, user experience topic, etc, but when things are going really wrong with your CRP, it's most definitely an SEO concern as well.

[edited by: ergophobe at 5:14 pm (utc) on Mar 28, 2017]

NickMNS

5:11 pm on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm guilty of Bootstrap, JS, and external Fonts, always from their CDNs. My view is that as long as one is using commonly used resources then there is good chance the users already have the resource cached.

I have minified that file (Pagespeed is happy with that) and I load it async,

How can you async the CSS if you need it to render ATF content? How can you start rendering without the CSS? And if you can render without the CSS, then how is it blocking?

ergophobe

5:59 pm on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



How can you async the CSS if you need it to render ATF content?


Good question. Or let's start with the precursor question - what method are you using to load CSS asynchronously?

There are a lot of methods I've seen mentioned, including

- Javascript-based CSS loaders, similar to Javascript loaders.

- the new rel="preload" attribute [w3.org], but that is only supported by Chrome right now [caniuse.com] but Filament Group has a LoadCSS polyfill [github.com]

And various hacks

- calling the stylesheet once in the head with a bogus media type (because non-matching media stylesheets are non-blocking) and then again before the closing body tag* with the right media type, the theory being that it will download the non-blocking file as soon as it can, but not sooner. There are supposedly a lot of problems with this technique

- putting the stylesheet link in the body* near the top which is allowed in HTML 5. Taylor Hunt has some tests [codepen.io] to show this is non-blocking in most browsers, but it isn't a spec, it's just a behavior that happens and can't really be counted on.


*A source of some confusion, but yes link[rel=stylesheet] is allowed in the body
Keywords that are body-ok affect whether link elements are allowed in the body. The body-ok keywords defined by this specification are prefetch, and stylesheet.
--http://w3c.github.io/html/links.html#body-ok


So, assuming it's loading async, I would imagine that if it's used above the fold, then there's a restyle (i.e. the canvas is redrawn) once the stylesheet actually loads.

NickMNS

6:25 pm on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



But doesn't redrawing the canvas defeat the purpose?
Then at a minimum would it not make sense to in-line the styling for sizing and positioning and then add colors and effects from the style sheet once it is loaded?

not2easy

7:26 pm on Mar 28, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I use inline for layout essentials (about 1.3 - 1.8kb), and a css file linked at the bottom of the page (2.5 - 3.5kb) for styling/colors. I don't use any external fonts or js. I have never noticed any delay in loading the styling css at the end of the page.

ergophobe

7:39 pm on Mar 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>>I have never noticed any delay in loading the styling css at the end of the page.

Which is probably a measure of how well your other measures are working and how minimal the resource load is. If you had blocking resources above it, things would get ugly I think.

not2easy

10:26 pm on Mar 28, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



True, I would not want 'everyone' to do what I do. I don't do that on all the sites I manage. It does not suit a lot of sites, and always test it to pieces. Function is important, just saying not every site needs all kinds of bells and whistles. If the site is plain old html5 and some php, with text and images it doesn't require extreme external overhead.

tangor

7:25 am on Mar 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



JS and other things that might be third party are usually needed for "eye candy". If a site does not require eye candy then don't use it .... and gain all kinds of speed by serving direct. :)

Meanwhile, in some cases, CDN actually does make sense, but on case by case instances. It is not something I would routinely recommend.

Involving others in my content delivery just makes me antsy .... If they go down, for any reason or length of time, that would affect my site(s), so I avoid that like the plague. That said, I'm not a Luddite ... sometimes JS is the solution, sometimes third party is required.

But if you can roll your own (and serve your own ads along with the content) you're ahead of the game and beholden to none. (Aside: this is not for the faint of heart or those who require "cut and paste" to make an income)

NickMNS

1:28 pm on Mar 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



JS and other things that might be third party are usually needed for "eye candy".

This may have been true in the past but I don't think this holds anymore unless you are talking about a very simple static websites.

In my case, I make extensive use of js/jQuery and AJAX to deliver content and key functionality to the user. I'm sure that I could work around it but the UX would be far worse. Whereas, I understand the logic of progressive enhancements, I don't see the logic in spending time, money and resources developing a website specifically to cater to user that are blocking js. Without js no ads are shown, my sites are monetized by ads. So why would I spend time and money for a very small subset of my users, specially when those user do not contribute directly to the bottom line?

In my experience CDNs have been far more reliable then my own server. It is true that even if the CDN is better, it is the combined risk (the sum) of both your server and CDN going down, because the probabilities are independent. But the risk of service interruption from the CDN is easily mitigated by providing a local fall-back. As such you get the benefit of the CDN without any additional risk.

keyplyr

6:39 pm on Mar 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



How can you async the CSS if you need it to render ATF content?
Good question, but as I said, in addition to a CSS sheet, I use a lot of inline.

pshea

10:20 pm on Mar 29, 2017 (gmt 0)

10+ Year Member



I have been paying a lot of attention to above the fold issues and have been moving up in SERPS. The per-page CSS is a PIA though.

ergophobe

8:11 pm on Apr 3, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>>per-page CSS is a PIA though.

Are you doing it manually?