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 #21677 · 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 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.

All reactions
@aryanraj45
feat(html): add optimization.minimize.html.tagOmission
b9dfc57
§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.
@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b9dfc57

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
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

👋 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.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot closed this 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

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

  • webpack/webpack#21649: Modifies related optional end-tag omission logic in lib/html/syntax.js.
  • webpack/webpack#21663: Extends the same HTML minimization option and processing pipeline.

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.

All reactions

Sorry, something went wrong.

Uh oh!

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

@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
refactor(css,html): derive the remaining name tables in the generators #21676
Merged
@aryanraj45

aryanraj45 commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

@alexander-akait @avivkeller can u please take a look at the bot behaviour

All reactions

Sorry, something went wrong.

Uh oh!

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

This was referenced Aug 11, 2026
feat(html): add optimization.minimize.html.tagOmission #21678
Closed
feat(html): let the minimizer keep attribute values as written #21682
Closed
feat(html): offer dropping an attribute that restates the default #21685
Merged
fix(html): read past the whitespace collapseWhitespace removes when omitting an end tag #21694
Closed
fix(html): parse processing instructions #21695
Merged
feat(html): leave out the implied <html> tag, and align the minify option surface #21700
Merged
feat(html): minify svg, standalone and inside css #21714
Closed
fix(html): drop a shell tag kept for whitespace that prints nothing, and respell escaped quotes #21717
Merged
perf(html): cut HTML minify time by re-using what the parse already computed #21725
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Aug 19, 2026
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

No reviews

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.

1 participant

@aryanraj45
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.