Skip to content

feat: embed main CSS inline instead of preloading#2487

Merged
aeneasr merged 3 commits intomasterfrom
css-embed
Mar 25, 2026
Merged

feat: embed main CSS inline instead of preloading#2487
aeneasr merged 3 commits intomasterfrom
css-embed

Conversation

@aeneasr
Copy link
Copy Markdown
Member

@aeneasr aeneasr commented Mar 25, 2026

Summary

  • Replaces <link rel="preload" as="style"> with an inline <style> block containing the full CSS content
  • Removes the <link rel="stylesheet"> Docusaurus injects for the same file to prevent double-loading
  • Renames plugin internals from preload-cssembed-css

Test plan

  • Run npm run build and inspect a generated HTML file in build/ — confirm a <style> block is present in <head> with Tailwind/theme CSS
  • Confirm no <link rel="stylesheet" href="...styles.*.css"> remains in the output HTML
  • Run npm run serve and verify styles render correctly with no flash of unstyled content

🤖 Generated with Claude Code

Replaces the <link rel="preload"> hint with a <style> block containing
the inlined CSS content, eliminating the extra network round-trip.
Also removes the Docusaurus-generated <link rel="stylesheet"> for the
same file to prevent double-loading.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
String matching on the <link> tag was fragile due to attribute order.
Switch to cheerio so we select by attribute values regardless of order,
and replaceWith() drops the external link and inlines the <style> block
in one step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Avoids a DOM parsing dependency for a simple string replacement.
The regex matches the href regardless of attribute order.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aeneasr aeneasr merged commit 205eb9a into master Mar 25, 2026
10 checks passed
@aeneasr aeneasr deleted the css-embed branch March 25, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants