(This is the first wikimedia bug I've filed; apologies if I do anything wrong. I'm a Mozilla Firefox developer reporting a performance issue aka opportunity-for-optimization.)
If you capture a Firefox or Chrome performance profile[1] of the https://en.wikipedia.org/wiki/Barack_Obama pageload, you'll see multiple 20-70ms restyles happening, as a result of separate calls to "addEmbeddedCSS".
SUGGESTION: This could be optimized quite a bit these addEmbeddedCSS calls all happened in the same tick (rather than spread out over time) -- then, they'd just produce a single restyle, which would likely still be about as long (or maybe slightly longer) than the duration of just one of these restyles we're already performing currently.
DETAILS/NOTES:
Here's a performance profile from Firefox Nightly, showing a portion of pageload:
https://perfht.ml/2jqZj5J
All of the "red bar followed by dark blue bar" patterns in the graphical waterfall there are from wikipedia's JS calling addEmbeddedCSS() to append a <style> element, and then styles are recalculated in the next refresh tick after the JS has yielded, in response to that new <style> element. If you hover those blue bars, you can see that each restyle takes on the order of ~40ms, and that's much longer than the frame budget for buttery-smooth 60fps performance. It's likely that wikipedia loading would be noticeably less janky if these many addEmbeddedCSS calls could be batched together.
I captured a Chrome profile as well, and noticed similar durations for post-addEmbeddedCSS restyles, as noted in https://bugzilla.mozilla.org/show_bug.cgi?id=1382311#c9 , but they don't have a web UI so I can't easily share that profile. But anyway, that indicates that this isn't Firefox-specific -- there are slow restyles in response to these calls in Chrome as well. So: my suggestion here would likely benefit load performance & responsiveness in all browsers.
[1] In Firefox, you can capture a profile using the extension from https://perf-html.io/ . In Chrome, you can use the built-in devtools.