News for hackers. Stuff that matters.
Re:How we improved our website's performance by seanwilson on Sunday January 24, 2021 @04:19PM (#25896185)
> Around the same time we switched from an (outdated) manually created critical CSS file to an automated system that was generating critical CSS for every template — homepage, article, product page, event, job board, and so on — and inline critical CSS during the build time. Yet we didn’t really realize how much heavier the automatically generated critical CSS was.

Is reducing the total amount of CSS per page so you don't have to calculate the critical CSS at all an option?

To throw my own page into the ring, here's a non-trivial product website of mine where the homepage is 0.3MB total over the wire and renders in 0.4 seconds for me (includes custom fonts, payments, analytics, large screenshot and real-time chat widget):

https://www.checkbot.io/

The major tricks I'm using is keeping the website CSS small (CSS for homepage + rest of site gzips to less than 8KB), inlining all CSS, rendering default fonts before the custom font has loaded, SVG for all images (this saves a ton), and not using JavaScript for content (which blocks rendering).

The screenshot in the header is in SVG format and inlined directly into the page along with the CSS, so the moment the HTML arrives the browser can display all above the fold content. Logos are another good one for the SVG + inline treatment.

Re:How we improved our website's performance by markdown on Sunday January 24, 2021 @04:30PM (#25896271)
The problem with inlining all CSS is serving all the global styles all over again with every page load. You're gaining a great first impression at the cost of a poorer experience for every subsequent page load.

Have you considered inlining CSS in the head (as you've done), but then serving it again with a linked css file just before </body>.

Then, with subsequent page loads (of the current or other pages), you don't have to inline any CSS anymore.

Of course this requires that you serve two versions of all your pages, one for if that page is a first hit, and another to be served to users who already have your CSS cached.

Re:How we improved our website's performance by seanwilson on Sunday January 24, 2021 @04:46PM (#25896445)
> The problem with inlining all CSS is serving all the global styles all over again with every page load.

> You're gaining a great first impression at the cost of a poorer experience for every subsequent page load.

Yep, it's unfortunate we still have to make tradeoffs like this. At least in this case, it's less than 8KB added per page vs something more complicated that might break.

HTTP push was getting closer to offering some alternative like what you're suggesting (the server pushes the CSS file to the client in parallel to the initial HTML page, and the client can say if it already has the CSS file) but it's being deprecated now.

Re:How we improved our website's performance by sdoering on Sunday January 24, 2021 @04:39PM (#25896374)
But with 8kb zipped (I assume that following pages aren't that much worse) why should one optimize with a solution that adds that much complexity?

I believe that shaving a few additional kb from this already low number isn't worth the proposed complexity.

But this is a tradeoff that everybody has to decide for themselves.

Re:How we improved our website's performance by markdown on Sunday January 24, 2021 @05:07PM (#25896645)
> But with 8kb zipped (I assume that following pages aren't that much worse) why should one optimize with a solution that adds that much complexity?

If that's the argument, why not just let them take the (tiny) initial 8kb hit as an external css file, and make the rest of the experience even "zippier"?

Re:How we improved our website's performance by seanwilson on Sunday January 24, 2021 @05:12PM (#25896701)
> why not just let them take the (tiny) initial 8kb hit as an external css file,

One reason is Google will likely ding your Core Web Vitals score for it, which is becoming a ranking signal in May this year (https://developers.google.com/search/blog/2020/11/timing-for...) so you have less of a choice here for what you prioritise.

Re:How we improved our website's performance by sdoering on Monday January 25, 2021 @01:50AM (#25900111)
I would believe that 8k via an additional request would harm performance more than to inline it.

But haven't tested that yet.

Re:How we improved our website's performance by markdown on Monday January 25, 2021 @05:23AM (#25901610)
It would most certainly marginally harm performance a single time, but every additional page load would be much improved.
Re:How we improved our website's performance by charrondev on Sunday January 24, 2021 @04:35PM (#25896326)
Unfortunately this means it’s difficult to handle HTTP caching without having something in the URL, and at the same time you want to make sure search engines index the version without the indicator in the URL.
Re:How we improved our website's performance by nicbou on Sunday January 24, 2021 @04:39PM (#25896377)
Inlining is a measured risk. If your CSS is sufficiently small, and the number of pages per visit is low, it's still faster than cached CSS.
Re:How we improved our website's performance by joegahona on Sunday January 24, 2021 @09:10PM (#25898284)
> The problem with inlining all CSS is serving all the global styles all over again with every page load. You're gaining a great first impression at the cost of a poorer experience for every subsequent page load.

The vast majority of users will visit one and only one page.

Re:How we improved our website's performance by httpsterio on Sunday January 24, 2021 @10:41PM (#25898797)
why would you optimize your website for someone who only visits the one page?
Re:How we improved our website's performance by seanwilson on Sunday January 24, 2021 @11:19PM (#25899064)
On the extreme end, consider someone on a spotty and slow mobile connection going through Google results to find what they want. They're only going to give you a few seconds before they hit "back" on your site and try another. The round trip for the browser to fetch the CSS file after the HTML file arrives can be enough to cause that delay.
Re:How we improved our website's performance by phist_mcgee on Sunday January 24, 2021 @10:53PM (#25898861)
Because for every second of delay you add, you reduce your potential audience by a large degree. You optimise for first impressions, even though you know that a major proportion will click away anyway.
Re:How we improved our website's performance by austhrow743 on Sunday January 24, 2021 @11:58PM (#25899403)
Because most days you don't add more than one piece of content.
Re:How we improved our website's performance by onion2k on Monday January 25, 2021 @01:08AM (#25899884)
You'd need to add 'rel="prefetch"' to the link or the browser will block rendering until the CSS file has been downloaded, parsed, and added to the CSSOM.
Re:How we improved our website's performance by mro_name on Monday January 25, 2021 @03:13AM (#25900702)
true, but if the 1st impression is great and the 2nd isn't worse – what else do we want?
Re:How we improved our website's performance by ramraj07 on Sunday January 24, 2021 @04:28PM (#25896254)
That's one of the fastest loading modern pages I've ever been to. Kudos!
Re:How we improved our website's performance by seanwilson on Sunday January 24, 2021 @07:14PM (#25897585)
Thanks! I wouldn't mind seeing a list of fast loading pages like this that have images + functionality that aren't mostly text. There's only so much you can do if your design requires large photos or a video in the header though.
Re:How we improved our website's performance by dingleberrydon on Monday January 25, 2021 @01:35AM (#25900018)
Whoa. I've never seen a page load this fast. How did you do it? Is there a blog post somewhere?
Re:How we improved our website's performance by seanwilson on Monday January 25, 2021 @03:54AM (#25900986)
I need to write it up but the SVG screenshot is documented on https://www.checkbot.io/article/web-page-screenshots-with-sv... and I'm using all the tricks from https://www.checkbot.io/guide/speed/ that the Chrome extension checks for.

The big wins are: don't require JS for any content in the page header, use minimal CSS + inline it, strongly prefer SVG images over bitmaps + inline them, use "font-display: swap" + go easy with how many fonts you need.

Re:How we improved our website's performance by siquick on Sunday January 24, 2021 @07:50PM (#25897808)
Just wanted to say that I’ve been using Checkbot for years and it’s great
Re:How we improved our website's performance by seanwilson on Monday January 25, 2021 @03:55AM (#25900993)
Thanks, that made my day. :)
Re:How we improved our website's performance by mro_name on Monday January 25, 2021 @03:08AM (#25900667)
phantastic. Design is not how something looks, it is how it works. (said Steve Jobs)

Do you folks know the entertaining talk http://idlewords.com/talks/website_obesity.htm?

Re:How we improved our website's performance by boundlessdreamz on Monday January 25, 2021 @03:46AM (#25900927)
How did you create the screenshot SVG and other SVGs?
Re:How we improved our website's performance by seanwilson on Monday January 25, 2021 @03:53AM (#25900980)
SVG screenshots are documented here: https://www.checkbot.io/article/web-page-screenshots-with-sv...

The main trick is to view your web app in a browser, print to PDF and then use Inkscape to auto convert from PDF -> SVG (with some caveats). Worst case you could recreate the screenshot from scratch in a vector editor.

The SVG icons are licensed from https://icons8.com/ (recommended!).

Re:How we improved our website's performance by boundlessdreamz on Monday January 25, 2021 @07:31AM (#25902408)
Thank you. You have been tremendously helpful