GeezerVison is showing github.com — feat(html): add optimization.minimize.html.tagOmission by aryanraj45 · Pull Request #21677 · webpack/webpack
Conversation
aryanraj45
commented
Aug 11, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
§13.1.2.4 lets the <html>, <head> and <body> tags be left out where the parser implies them, and webpack emits all six. This adds the option that takes them out, with the same shape @swc/html uses: true drops all six, "keep-head-and-body" drops only <html>.
The safe mode exists because a page without a <body> is still valid HTML but a crawler matching on it with a regexp rather than a parser will not find one — instagram/facebook style scrapers being the case that matters.
A tag stays wherever the spec keeps it: an attribute to carry, a comment minification does not drop, whitespace after </head>, or a meta / link / script / style / template opening the body. Measured over html5-boilerplate, swagger-ui and the rendered README and CHANGELOG: 93 gzip bytes for true, 29 for "keep-head-and-body".
What kind of change does this PR introduce?
feat
Did you add tests for your changes?
Yes — test/configCases/html/minimize-tag-omission and minimize-tag-omission-keep-head-body, snapshotting the emitted pages for both modes plus the cases that must keep a tag. Every new line is covered. The output was also checked against parse5 over 28 fixtures in both modes: the DOM is identical to what the same build emits with the option off.
Does this PR introduce a breaking change?
No. The option is off by default and the emitted HTML is unchanged without it.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
optimization.minimize.html.tagOmission on the configuration page. The CLI flag is generated from the schema already.
Use of AI
AI was used. I decided the option shape and the safe default, and used Claude Code to implement the spec rules, write the cases and run the suites. I reviewed the change myself — that pass caught a hot-path regression (every element was calling the new check even with the option off), a dead branch, and a normalization that let a junk option value through.
Summary by CodeRabbit
-
New Features
- Added HTML tag omission controls for minimized output.
- Supports omitting implied
<html>, <head>, and <body> tags.
- Added
"keep-head-and-body" mode to preserve document shell tags while minimizing other markup.
- Preserves required tags when attributes, comments, whitespace, or document structure require them.
-
Tests
- Added coverage for standard and shell-preserving tag omission scenarios.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
§13.1.2.4 lets the <html>, <head> and <body> tags be left out where the parser
implies them, and the option takes them out: true drops all six, and the
"keep-head-and-body" mode drops only <html>, since a crawler matching on
<body> with a regexp rather than a parser would not find one.
A tag stays wherever the spec keeps it — an attribute to carry, a comment
minification does not drop, whitespace after </head>, or an element the parser
still reads as head content opening the body.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
👋 Hi there! This PR was automatically flagged and closed by our quality checks.
If you believe this was a mistake, please review our contributing guidelines
and leave a comment explaining why this is a mistake.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Aug 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Caution
Review failed
The pull request is closed.
Note
.coderabbit.yaml has unrecognized properties
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "tools"
⚙️ Configuration instructions
- Please see the configuration documentation for more information.
- You can also validate your configuration using the online YAML validator.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ce7062c2-1f31-4707-b998-9befbea529f0
📥 Commits
Reviewing files that changed from the base of the PR and between 4015bbd and b9dfc57.
⛔ Files ignored due to path filters (9)
declarations/WebpackOptions.d.ts is excluded by !declarations/**
lib/html/data.js is excluded by !lib/html/data.js
schemas/WebpackOptions.check.js is excluded by !schemas/**/*.check.js
test/__snapshots__/Cli.basictest.js.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
test/configCases/html/minimize-tag-omission-keep-head-body/__snapshots__/ConfigCacheTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
test/configCases/html/minimize-tag-omission-keep-head-body/__snapshots__/ConfigTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
test/configCases/html/minimize-tag-omission/__snapshots__/ConfigCacheTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
test/configCases/html/minimize-tag-omission/__snapshots__/ConfigTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
types.d.ts is excluded by !types.d.ts
📒 Files selected for processing (16)
.changeset/159-html-tag-omission.md
lib/html/htmlMinify.js
lib/html/syntax.js
lib/util/SourceProcessor.js
schemas/WebpackOptions.json
test/configCases/html/minimize-tag-omission-keep-head-body/index.js
test/configCases/html/minimize-tag-omission-keep-head-body/page.html
test/configCases/html/minimize-tag-omission-keep-head-body/test.config.js
test/configCases/html/minimize-tag-omission-keep-head-body/webpack.config.js
test/configCases/html/minimize-tag-omission/head-content.html
test/configCases/html/minimize-tag-omission/index.js
test/configCases/html/minimize-tag-omission/kept-comment.html
test/configCases/html/minimize-tag-omission/page.html
test/configCases/html/minimize-tag-omission/test.config.js
test/configCases/html/minimize-tag-omission/webpack.config.js
tooling/generate-html-data.js
📝 Walkthrough
Walkthrough
Changes
HTML tag omission
| Layer / File(s) |
Summary |
Option contracts and wiring schemas/WebpackOptions.json, lib/util/SourceProcessor.js, lib/html/htmlMinify.js, tooling/generate-html-data.js |
Adds optimization.minimize.html.tagOmission with boolean and "keep-head-and-body" modes. The option reaches the HTML printer. |
Shell-tag omission rules lib/html/syntax.js |
Adds omission checks for <html>, <head>, and <body> tags. The rules account for attributes, comments, whitespace, and parser-sensitive content in streamed and composed output. |
Webpack integration validation test/configCases/html/minimize-tag-omission/*, test/configCases/html/minimize-tag-omission-keep-head-body/*, .changeset/159-html-tag-omission.md |
Adds configuration cases, HTML fixtures, snapshot checks, and a minor release changeset for the new option. |
Possibly related PRs
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
lib/html/htmlMinify.js
Unused eslint-disable directive (no problems were reported from 'import/no-extraneous-dependencies').
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Aug 11, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
area: config
Options, defaults, validation (lib/config, schemas/)
area: html
Experimental HTML support (lib/html)
area: tooling
Repo tooling, codegen, CLI entry (tooling/, bin/)
area: types
types.d.ts, JSDoc annotations, hand-maintained declarations
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|