-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Adds streaming HTMLRewriter content docs and changelog #19578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| import { Render, TypeScriptExample } from "~/components"; | ||
|
|
||
| [`HTMLRewriter`](/workers/runtime-apis/html-rewriter) now supports replacing HTML with content from a stream. |
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.
speak 2nd person — you can now...
|
|
||
| [`HTMLRewriter`](/workers/runtime-apis/html-rewriter) now supports replacing HTML with content from a stream. | ||
|
|
||
| This allows you to process HTML more efficiently, as content does not have to be loaded into memory before replacements are made. |
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.
before and after?
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.
I think it's just before because you would've await'd response.body previously, then passed in the string
src/content/changelogs-next/2025-02-03-html-rewriter-streaming.mdx
Outdated
Show resolved
Hide resolved
irvinebroque
left a comment
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.
Think we can do a bit more here to speak directly to use case
ex:
- I have some site, some origin
- I have a Worker in front
- In my Worker, I need to transform the HTML response — for example, I need to insert a
<script>tag into the page - Before — I had to fetch the entire response object from the origin, and only after getting the whole response, I could pass that response into
HTMLRewriter. This made things slower, because it prevented streaming the bytes of the response back to the client, as I receive them from the origin - After — I can pass the response directly in, and HTMLRewriter can immediately start parsing and handling rewriting content as it receives bytes of the response, and stream that back to the client immediately
Deploying cloudflare-docs with
|
| Latest commit: |
3dcbcaf
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://326df2ed.cloudflare-docs-7ou.pages.dev |
| Branch Preview URL: | https://mnomitch-streaming-html-rewr.cloudflare-docs-7ou.pages.dev |
|
Files with changes (up to 15)
|
|
@irvinebroque - gave it another pass |
Summary
Adds documentation and a changelog for recent updates to HTMLRewriter that allow for streamed content.