cloudflare · Cloudflare Workers Docs
Workers HTMLRewriter
Explains how to use the HTMLRewriter class to parse and transform HTML content within a Cloudflare Worker using element and document handlers.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Workers HTMLRewriter
Explains how to use the HTMLRewriter class to parse and transform HTML content within a Cloudflare Worker using element and document handlers.
When To Use
Use when you need to programmatically parse, modify, or inject content into an HTML stream during a request or response lifecycle in a Cloudflare Worker.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/workers-runtime-apis-html-rewriter-htmlrewriter-workflow-guide.md | A technical documentation guide detailing the HTMLRewriter class, including its constructor, global types, and handler implementation for parsing HTML within Cloudflare Workers. | Questions about a technical documentation guide detailing the HTMLRewriter class, including its constructor, global types, and handle... |
examples/workers-runtime-apis-html-rewriter-htmlrewriter-cloudflare-workers-htmlr.text | A text-based demonstration of initializing the HTMLRewriter class and using element and document handlers to manipulate HTML content. | Exact payloads, commands, or snippets shown in A text-based demonstration of initializing the HTMLRewriter class and using element and document handlers to manipula... |
examples/workers-runtime-apis-html-rewriter-htmlrewriter-cloudflare-workers-htmlr-2.text | A JavaScript implementation demonstrating how to use the HTMLRewriter class with an ElementHandler to intercept and log div elements, comments, and text nodes. | Exact payloads, commands, or snippets shown in A JavaScript implementation demonstrating how to use the HTMLRewriter class with an ElementHandler to intercept and l... |
examples/workers-runtime-apis-html-rewriter-htmlrewriter-cloudflare-workers-htmlr-3.text | A text implementation of the DocumentHandler class used to intercept and manipulate HTML elements via the Workers HTMLRewriter API. | Exact payloads, commands, or snippets shown in A text implementation of the DocumentHandler class used to intercept and manipulate HTML elements via the Workers HTM... |
examples/workers-runtime-apis-html-rewriter-htmlrewriter-cloudflare-workers-htmlr-4.text | A JavaScript implementation demonstrating how to use the HTMLRewriter class to intercept and modify specific HTML elements using a custom handler class. | Exact payloads, commands, or snippets shown in A JavaScript implementation demonstrating how to use the HTMLRewriter class to intercept and modify specific HTML ele... |
examples/workers-runtime-apis-html-rewriter-htmlrewriter-cloudflare-workers-htmlr-5.text | A JavaScript implementation of an ElementHandler class used to manipulate HTML elements via the Workers HTMLRewriter API. | Exact payloads, commands, or snippets shown in A JavaScript implementation of an ElementHandler class used to manipulate HTML elements via the Workers HTMLRewriter... |
examples/workers-runtime-apis-html-rewriter-htmlrewriter-cloudflare-workers-htmlr-6.text | A JavaScript implementation of a DocumentHandler class used with the Workers HTMLRewriter API to intercept and modify HTML elements. | Exact payloads, commands, or snippets shown in A JavaScript implementation of a DocumentHandler class used with the Workers HTMLRewriter API to intercept and modify... |
examples/workers-runtime-apis-html-rewriter-htmlrewriter-cloudflare-workers-htmlr-7.text | A JavaScript implementation of a DocumentHandler class used with the Workers HTMLRewriter API to process HTML elements. | Exact payloads, commands, or snippets shown in A JavaScript implementation of a DocumentHandler class used with the Workers HTMLRewriter API to process HTML elements. |
examples/workers-runtime-apis-html-rewriter-htmlrewriter-cloudflare-workers-htmlr-8.text | A JavaScript code example demonstrating how the HTMLRewriter throws an error during the transformation process when an element handler encounters an exception. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how the HTMLRewriter throws an error during the transformation process when a... |
What This Skill Covers
- The HTMLRewriter class allows developers to build comprehensive and expressive HTML parsers inside of a Cloudflare Workers application. It can be thought of...
- Main sections:
Background,Constructor,Global types,Handlers,Element Handlers.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://developers.cloudflare.com/workers/runtime-apis/html-rewriter
