Sara Joy :happy_pepper: on Nostr: Finding it difficult to avoid FOUC-ing up (Flash Of Unstyled Content) when switching ...
Finding it difficult to avoid FOUC-ing up (Flash Of Unstyled Content) when switching out or adding in a linked stylesheet to the head via JS.
I thought normal JS scripts in the head would block render - and I suppose they do but then there's still a split second or more of no stylesheet while the switch is taking place and it rerenders.
Is there a way to make it less flashy without resorting to hacks like making html/body invisible until the last line of CSS is parsed?
#CSS #JavaScript #FOUC
Published at
2024-10-07 13:44:46Event JSON
{
"id": "ca2b45c972d65645eba0d2f20826929c54d58160a2b4a010d5baaffd2679b9ff",
"pubkey": "9049fc0299d6db89f82d002bd25a7016583293b600f674a90c5bf5ea3a23835c",
"created_at": 1728308686,
"kind": 1,
"tags": [
[
"t",
"css"
],
[
"t",
"fouc"
],
[
"t",
"javascript"
],
[
"proxy",
"https://front-end.social/@sarajw/113266438087536109",
"web"
],
[
"proxy",
"https://front-end.social/users/sarajw/statuses/113266438087536109",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://front-end.social/users/sarajw/statuses/113266438087536109",
"pink.momostr"
],
[
"-"
]
],
"content": "Finding it difficult to avoid FOUC-ing up (Flash Of Unstyled Content) when switching out or adding in a linked stylesheet to the head via JS.\n\nI thought normal JS scripts in the head would block render - and I suppose they do but then there's still a split second or more of no stylesheet while the switch is taking place and it rerenders.\n\nIs there a way to make it less flashy without resorting to hacks like making html/body invisible until the last line of CSS is parsed?\n\n#CSS #JavaScript #FOUC",
"sig": "76c0fba7fcc8da696b0b06b2f6382f744b60966e7abc631da89cf69febf515201819c153cca201644501c07d10fc1c9c0252f5533b388bc8c83888dba35109b8"
}