#How to defer non critical CSS?

1 messages · Page 1 of 1 (latest)

faint harbor
#

I'm trying to implement the approach documented here: https://web.dev/defer-non-critical-css/#optimize

But I'm having trouble because it seems React doesn't support adding a string onload attribute. Plus, dangerouslySetInnerHTML would require a wrapper element, which I think is disallowed in head.

Wondering if anyone knows how to accomplish this with Remix? I assume using a non-string onload would be bad because the event handler would only be added after JS loads

web.dev

Learn how to defer non-critical CSS with the goal of optimizing the Critical Rendering Path, and improving FCP (First Contentful Paint).

#

Welp, looks like that hack only works for the initial rendering on the server. Then hydration fails on the client because the number of elements is unexpected

worthy bridge
faint harbor
#

Huh, didn't realize adding both with and without preload would make the latter non-blocking!

Curious if you know why https://web.dev/defer-non-critical-css/#optimize would recommend their approach if there's a seemingly simpler option?

web.dev

Learn how to defer non-critical CSS with the goal of optimizing the Critical Rendering Path, and improving FCP (First Contentful Paint).

worthy bridge
#

Not too sure. I learned the trick from @turbid mural. The blog is from 2019, so maybe web standards changed for the better?