Skip to content

fix(minifier): Keep attribute quotes in the SWC HTML minifier - #12369

Merged
slorber merged 1 commit into
facebook:mainfrom
Hashim1999164:fix/keep-swc-html-attribute-quotes
Aug 21, 2026
Merged

fix(minifier): Keep attribute quotes in the SWC HTML minifier#12369
slorber merged 1 commit into
facebook:mainfrom
Hashim1999164:fix/keep-swc-html-attribute-quotes

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #12368

The SWC HTML minifier drops quotes from attributes, so og:image becomes property=og:image. WhatsApp then ignores the image in link previews.

Passing quotes: true keeps quoted attributes while still using the fast SWC minifier. The Terser HTML minifier path already keeps quotes.

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Aug 19, 2026
@netlify

netlify Bot commented Aug 19, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 3b459db
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a85c54a42730b000884d338
😎 Deploy Preview https://deploy-preview-12369--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@akash-sharma8

Copy link
Copy Markdown

I independently reproduced the issue and verified the same fix locally with quotes: true.

I also added a regression test to ensure HTML attribute quotes are preserved, and verified that the test fails when quotes: true is removed.

The full test suite passes locally: 184 test files / 2944 tests.

So I can confirm this approach fixes the issue from my side as well. Thanks!

@akash-sharma8

Copy link
Copy Markdown

I also verified the fix on the PR deploy preview.

The generated HTML now preserves the attribute quotes:

I also tested the PR deploy URL in WhatsApp, and the Open Graph image is rendered correctly in the link preview.

So this confirms that quotes: true preserves the attributes as intended and resolves the compatibility issue described in #12368

@johnnyreilly

Copy link
Copy Markdown
Contributor

I also tested the PR deploy URL in WhatsApp, and the Open Graph image is rendered correctly in the link preview.

The screenshot from @slorber here:

#12368 (comment)

Show the open graph image preview not working in WhatsApp. But you say it works for you?

@akash-sharma8

Copy link
Copy Markdown

Yes — I tested the exact PR deploy URL in WhatsApp from my side, and the Open Graph image is rendered correctly in the preview.

I also verified the generated HTML directly and confirmed that the og:image attributes are quoted:

So the fix does preserve the attribute quotes as intended. The difference in results may be related to WhatsApp's preview caching. I've attached a screenshot of the WhatsApp preview from my side for reference.

Screenshot 2026-08-21 103502

@johnnyreilly

Copy link
Copy Markdown
Contributor

Actually I have been bitten by the caching - I had to restart my phone in between testing to flush it (possibly there's easier methods)

@akash-sharma8

Copy link
Copy Markdown

That makes sense — thanks for confirming! I also suspected WhatsApp caching since the PR deploy was working correctly on my side.

@slorber slorber added pr: bug fix This PR fixes a bug in a past release. to backport This PR is planned to be backported to a stable version of Docusaurus labels Aug 21, 2026
@slorber

slorber commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

hmmm weird, now it works for me while it didn't before

LGTM

@slorber

slorber commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator
CleanShot 2026-08-21 at 15 26 00@2x

@slorber slorber changed the title Keep attribute quotes in the SWC HTML minifier fix(SEO): Keep attribute quotes in the SWC HTML minifier Aug 21, 2026
@slorber slorber changed the title fix(SEO): Keep attribute quotes in the SWC HTML minifier fix(minifier): Keep attribute quotes in the SWC HTML minifier Aug 21, 2026
@slorber
slorber merged commit 37a57ae into facebook:main Aug 21, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release. to backport This PR is planned to be backported to a stable version of Docusaurus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aggressive tag optimisation with faster - quotes are stripped which breaks og:image in WhatsApp

4 participants