Earlier quoted context omitted.
Also, since they are talking about optimization, I wonder why they make embedded fonts a requirement to view their plain-text page. I disable loading of fonts because it's useless and often slows everything down, and this is how their page look without these fonts: http://i.imgur.com/oDO8gRt.png
I imagine the vast majority of web users have font loading enabled so they optimised and tested for that.
Google recommends inlining small CSS
51–60 of 143 posts
Re: Google recommends inlining small CSS
#52Re: Google recommends inlining small CSS
#53I remember a CSS class in some enterprise software I was working on several years ago: /* bold */ .bold { font-weight: bold !important; } It has became my favourite real-world example of CSS misusage :)
I don't see what's wrong here - they come in handy when you need a one-time style alteration.
Re: Google recommends inlining small CSS
#54I remember a CSS class in some enterprise software I was working on several years ago: /* bold */ .bold { font-weight: bold !important; } It has became my favourite real-world example of CSS misusage :)
Re: Google recommends inlining small CSS
#55The problem i've always had with this, and the "above the fold" rule as it appears in the pagespeed insights tool, is the definition of "fold" varies wildly. So I see CSS optimisation as a multi-step process. * Switch to a component-based rendering architecture (I favour React) * Map CSS rules directly to components (I use CSS Modules) * Have a JavaScript entry-point per route. The entry-point should only contain wha…
Does this have any negative effects on browser caching?
The other caveat is that the nature of generating common bundles automatically means that what's in those bundles will vary whenever the code is changed. This means that you'll lose the benefits of browser caching each time you release. If you have dependencies that you can guarantee will be in the common bundle (like it's safe to say React will always be in it, along with any other architectural libraries), then you're better off externalising them to somewhere that sticks around between releases (and therefore benefits more from browser caching). This will also make your common bundles much smaller.
Re: Google recommends inlining small CSS
#56The Node module UnCSS (https://github.com/giakki/uncss) is working reliably for us, using PhantomJS to automatically extract the CSS rules we need for our front page.
The full CSS rules are then loaded at the end of the page - just in case UnCSS missed a browser specific or Javascript triggered rule, and to get the files into the cache.
Re: Google recommends inlining small CSS
#57Interesting. The sample code includes this bit: var raf = requestAnimationFrame || mozRequestAnimationFrame || webkitRequestAnimationFrame || msRequestAnimationFrame; if (raf) raf(cb); else window.addEventListener('load', cb); I've never thought to use requestAnimationFrame like that. When exactly does it fire? Is that the preferred callback these days for loading code after the page is "done" in some fashion? I've g…
[1] https://github.com/jquery/jquery/blob/dabd5ba96c05279b3ffb05...
[2] https://developer.mozilla.org/en-US/docs/Web/API/window/requ...
Re: Google recommends inlining small CSS
#58Earlier quoted context omitted.
Seriously. CSS loading/parsing is render blocking. By loading CSS that isn't needed immediately asynchronously in a way that will use the browser cache if it's available, it makes the page visible much faster. It feels like overkill in the simple example, but it's a tried and true method. ( https://github.com/filamentgroup/loadCSS has > 2k stars if that kinda thing means anything) From my experience on a large websit…
In a few hours, I'm launching a very large website that relies heavily on LoadCSS(). Page load times have been excellent in the pre-public phase, even though our critical styles contain a mountain of Autoprefixer-generated flexbox prefixes. My understanding is that all of this will become an antipattern once we can support http/2. For today, however, it provides a very real performance boost.
Re: Google recommends inlining small CSS
#59Earlier quoted context omitted.
I imagine the vast majority of web users have font loading enabled so they optimised and tested for that.
So, ... screw the minority? Seriously, one of the benefits of the web stack is that it makes it very easy to cater for a wide variety of capabilities, rather than resorting to "Best viewed with Internet Explorer 5"-type behaviour.
If web developers had to support every permutation of turning off cookies, fonts, images, JavaScript, stylesheets etc. you'd never get anything done.
Re: Google recommends inlining small CSS
#60The problem i've always had with this, and the "above the fold" rule as it appears in the pagespeed insights tool, is the definition of "fold" varies wildly. So I see CSS optimisation as a multi-step process. * Switch to a component-based rendering architecture (I favour React) * Map CSS rules directly to components (I use CSS Modules) * Have a JavaScript entry-point per route. The entry-point should only contain wha…
Does this have any negative effects on browser caching?
For this reason, I think a better solution might be to inject critical styles into a STYLE tag in the HEAD, and then deliver one style file per component. The intuition behind this is that you can do your initial render with only the original payload (ideally in the first roundtrip), and that will buy you plenty of time for the cascade of web requests to get all the individual component files. With HTTP/2 multiplexing coming, there's no much penalty there. And then you get to cache your page at the granularity of a single component.