GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(html): add optimization.minimize.html.tagOmission by aryanraj45 · Pull Request #21678 · webpack/webpack

Conversation

@aryanraj45

@aryanraj45 aryanraj45 commented Aug 11, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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 shape @swc/html already 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 — the instagram/facebook class of scraper 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 / noscript / link / script / style / template element 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 — two cases under configCases/html, one per mode, snapshotting the emitted pages and the shapes that must keep a tag. Every added line is covered. The output was also compared 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; Claude Code implemented the spec rules and wrote the tests. I reviewed everything before pushing and fixed a few things it got wrong along the way.

Summary by CodeRabbit

  • New Features

    • Added configurable HTML tag omission during minification.
    • Use optimization.minimize.html.tagOmission to omit implied <html>, <head>, and <body> tags.
    • Supports retaining <head> and <body> while omitting only the outer <html> tags.
    • Preserves required attributes, comments, whitespace, and parser-sensitive content.
  • Tests

    • Added coverage for tag omission and preservation of document content.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@aryanraj45
feat(html): add optimization.minimize.html.tagOmission
fb6d5eb
§13.1.2.4 lets the <html>, <head> and <body> tags be left out where the parser
implies them. `true` drops all six, `"keep-head-and-body"` drops only <html>,
since a crawler matching on <body> with a regexp would not find one. A tag
stays wherever the spec keeps it.
@changeset-bot

changeset-bot Bot commented Aug 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 80c2109

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added area: config Options, defaults, validation (lib/config, schemas/) area: html Experimental HTML support (lib/html) area: types types.d.ts, JSDoc annotations, hand-maintained declarations area: tooling Repo tooling, codegen, CLI entry (tooling/, bin/) labels Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d46ae177-31ad-4883-acb9-6e931aa5bbf2

📥 Commits

Reviewing files that changed from the base of the PR and between fb6d5eb and 80c2109.

⛔ Files ignored due to path filters (2)
  • 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__/**
📒 Files selected for processing (4)
  • lib/html/syntax.js
  • test/configCases/html/minimize-tag-omission/index.js
  • test/configCases/html/minimize-tag-omission/leading-space.html
  • test/configCases/html/minimize-tag-omission/test.config.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • webpack/schema-utils (auto-detected)
  • webpack/tapable (auto-detected)
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/configCases/html/minimize-tag-omission/index.js
  • lib/html/syntax.js
  • test/configCases/html/minimize-tag-omission/test.config.js

📝 Walkthrough

Walkthrough

Adds optimization.minimize.html.tagOmission, forwards it through HTML processing, omits eligible document-shell tags, and adds configuration tests for unrestricted omission and keep-head-and-body.

Changes

HTML tag omission

Layer / File(s) Summary
Option contract and wiring
schemas/WebpackOptions.json, lib/util/SourceProcessor.js, lib/html/htmlMinify.js
Adds the tagOmission option and forwards it from HTML minimization to the print context.
Shell-tag printing
tooling/generate-html-data.js, lib/html/syntax.js
Adds shell-tag eligibility data and conditionally omits eligible <html>, <head>, and <body> tags.
Configuration and validation
test/configCases/html/minimize-tag-omission/*, test/configCases/html/minimize-tag-omission-keep-head-body/*, .changeset/159-html-tag-omission.md
Adds webpack configuration cases, fixtures, output assertions, and a release note for the new option.

Possibly related PRs

  • webpack/webpack#21649: Both changes modify HTML tag-omission logic in lib/html/syntax.js.
  • webpack/webpack#21663: This change extends the HTML minimizer options with tagOmission.
  • webpack/webpack#21677: This PR contains the same HTML minification, schema, generator, and test changes.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the required Conventional Commit format and accurately describes the added HTML tag omission option.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]
coderabbitai Bot reviewed Aug 11, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tooling/generate-html-data.js (1)

1238-1243: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Commit the generated HTML data module.

lib/html/syntax.js now reads BODY_START_KEPT_BEFORE, but this PR only changes its generator. Without the regenerated export, the imported value is undefined. With tagOmission: true and a body that starts with an element, _canOmitShellStart calls .has() and throws.

Regenerate and commit the generated HTML data output.

Also applies to: 1306-1311

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tooling/generate-html-data.js` around lines 1238 - 1243, Regenerate and
commit the generated HTML data module so the output exports
BODY_START_KEPT_BEFORE alongside the entries listed in EXPORT_NAMES. Ensure
lib/html/syntax.js receives a defined set for _canOmitShellStart when
tagOmission is enabled, rather than leaving the generated import undefined.
🧹 Nitpick comments (1)
test/configCases/html/minimize-tag-omission/index.js (1)

6-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace both tautological entry assertions with behavior checks.

Both entry tests assert a constant instead of verifying tag omission.

  • test/configCases/html/minimize-tag-omission/index.js#L6-L6: Assert unrestricted shell-tag omission through generated HTML or parsed DOM output.
  • test/configCases/html/minimize-tag-omission-keep-head-body/index.js#L4-L4: Assert that <head> and <body> remain while <html> tags are omitted.

As per path instructions, tests must use explicit assertions for behavior, invariants, equivalences, and errors.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/configCases/html/minimize-tag-omission/index.js` at line 6, Replace the
tautological assertion in
test/configCases/html/minimize-tag-omission/index.js:6-6 with explicit
assertions against generated HTML or parsed DOM output that verify unrestricted
shell-tag omission. Also replace the tautological assertion in
test/configCases/html/minimize-tag-omission-keep-head-body/index.js:4-4 with
assertions confirming <head> and <body> remain while <html> tags are omitted.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/html/syntax.js`:
- Around line 8611-8630: Update _canOmitShellStart so the body-omission branch
rejects a first text node when its initial character is HTML whitespace, rather
than relying on isAllWs(path.data(first)). Preserve omission for text beginning
with non-whitespace content, and add a regression fixture covering <body>
text</body>.

---

Outside diff comments:
In `@tooling/generate-html-data.js`:
- Around line 1238-1243: Regenerate and commit the generated HTML data module so
the output exports BODY_START_KEPT_BEFORE alongside the entries listed in
EXPORT_NAMES. Ensure lib/html/syntax.js receives a defined set for
_canOmitShellStart when tagOmission is enabled, rather than leaving the
generated import undefined.

---

Nitpick comments:
In `@test/configCases/html/minimize-tag-omission/index.js`:
- Line 6: Replace the tautological assertion in
test/configCases/html/minimize-tag-omission/index.js:6-6 with explicit
assertions against generated HTML or parsed DOM output that verify unrestricted
shell-tag omission. Also replace the tautological assertion in
test/configCases/html/minimize-tag-omission-keep-head-body/index.js:4-4 with
assertions confirming <head> and <body> remain while <html> tags are omitted.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 92c77e0a-c388-47dd-9b68-ccffbaf18760

📥 Commits

Reviewing files that changed from the base of the PR and between 4015bbd and fb6d5eb.

⛔ 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
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • webpack/schema-utils (auto-detected)
  • webpack/tapable (auto-detected)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/html/syntax.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@aryanraj45
fix(html): keep <body> when its text starts with whitespace
80c2109
§13.1.2.4 asks whether the first thing inside is whitespace, and isAllWs only
rejected an all-whitespace node, so " text" dropped the tag and the space then
landed in <head> on reparse. Same test for the whitespace after </head>.
@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
feat(html): let the minimizer keep attribute values as written #21682
Closed
@alexander-akait alexander-akait mentioned this pull request Aug 13, 2026
feat(html): leave out the implied <html> tag, and align the minify option surface #21700
Merged
@alexander-akait

alexander-akait commented Aug 13, 2026

Copy link
Copy Markdown
Member

Fixed in the main, co-author with you, thanks for working on it

aryanraj45 reacted with thumbs up emoji aryanraj45 reacted with heart emoji
All reactions
  • 👍 1 reaction
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait alexander-akait closed this Aug 13, 2026
@aryanraj45

aryanraj45 commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

Fixed in the main, co-author with you, thanks for working on it

thanks! closing #21694 in favour of this as yours covers it and does both directions, mine only did the forward scan

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Aug 16, 2026
fix(html): keep the end tags the parser cannot put back, and mirror <selectedcontent> as an engine does #21743
Merged
feat(html): minify the document an <iframe srcdoc> holds #21767
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

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

Projects

None yet

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.

2 participants

@aryanraj45 @alexander-akait
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.