Hacker News new | ask | show | jobs
by iand675 3304 days ago
I don't understand this part:

> If you don't have a CSS cookie set, I inline the CSS in the HTML, load the CSS file asynchronously with a slightly adapted loadCSS JavaScript, and set the cookie.

What is the purpose of the cookie here? Is CSS being stored in the cookie? Does the value of setting the cookie exceed using an Etag to only load the CSS if it's modified?

2 comments

I’ve reworded that bit, sorry, it wasn’t very clear!

It is as krallja says; inlined on the very first request (so any caching headers such as ETag wouldn't help, though I do set them for anything subsequent) so there is no display blocking fetching the CSS needed for display (as I have little CSS, I inline all of it, but you might want critical CSS only).

A missing cookie means the CSS is sent inline with the HTML, so it doesn't need to start another request to fetch the CSS.