-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
feat(core): faster HTML minimizer - siteConfig.future.experimental_faster.swcHtmlMinimizer
#10554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Size Change: -474 kB (-4.1%) Total Size: 11.1 MB
ℹ️ View Unchanged
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@argos-ci/playwright@1.9.3, npm/@mdx-js/react@1.0.1, npm/@netlify/functions@1.6.0, npm/@playwright/test@1.47.2, npm/cheerio@1.0.0 |
siteConfig.future.experimental_faster.swcHtmlMinimizer
**Description:** - `preserveComments` is optional but required in the TS type - `removeRedundantAttributes` is an enum and passing a boolean leads to errors See https://github.com/swc-project/swc/blob/main/crates/swc_html_minifier/src/option.rs#L54 **Related issue:** - facebook/docusaurus#10554
Answering @IntrepidToucan comment here directly on this PR to keep the Docusaurus Faster meta issue cleaner of this quite specific topic.
@IntrepidToucan Yes that's true, but it's considered an optimization built-in into the SWC minimizer by default. The following HTML is not malformed, it's spec compliant and pass W3C validation: <!doctype html>
<html lang=en>
<meta name=generator content="Docusaurus v3.7.0">
<title>Docusaurus changelog | Docusaurus</title>
<meta name=viewport content="width=device-width, initial-scale=1.0">
<body>
blabla https://validator.w3.org/nu/#textarea
This is not considered a bug, so we'd need to understand what issue this is causing exactly. Maybe it's your other tool that doesn't support valid HTML markup that needs to be fixed instead. If you provide a good reason, I'm open to introducing a new option to let you configure or provide your own minimizer, but I need to understand the problem first. |
Hi @slorber , that makes sense. I'll bring this information back to the team so they can update their logic to accept this as valid HTML. Thanks for the helpful context and fast followup! |
Docusaurus Faster
This PR is part of the Docusaurus Faster project aiming at reducing production build times
Motivation
The Docusaurus SSG step takes around ~7s, mainly because of HTML minification with
html-minifier-terser
being slow.This PR add an opt-in for the new
@swc/html
minifier, with the following results:Note: related SWC HTML minifier discussion: swc-project/swc#9616
Test Plan
CI + preview + argos
Test links
https://deploy-preview-10554--docusaurus-2.netlify.app/