Skip to content

@swc/html minifier option to disable removal of <head> and </body> #10994

@slorber

Description

@slorber

Describe the feature

The SWC html minifier removes the <head> and </body> closing tag attributes by default, as an optimization.

The following may be surprising, but it passes W3C validation, so SWC is technically right:

<!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

But it turns out that despite being valid HTML, this can cause troubles, notably for LinkedIn social cards. Apparently, the LinkedIn crawler expects those tags to be present to be able to find the og:image meta tag, and maybe this affects other sites as well.

For Docusaurus, we'd like to have an option in SWC minimizer to disable this built-in optimization. @kdy1 suggested opening a feature request here.

Babel plugin or link to the feature description

No response

Additional context

See also related Docusaurus discussions:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions