Workers DOM manipulation API - in a near-future roadmap?

Hi,

wanted to inquire how likely it is that dom manipulation API would become native for workers anytime soon? Or wasm is the direction CF workers team would like to see us heading towards?

Thanks!

There’s no first-party DOM manipulation in V8 since there is no DOM, so I wouldn’t bet on this being implemented by CF. I just don’t see them subsidizing dom manipulation’s CPU time specifically just because it’s generally broken by the CPU time limit.

2 Likes

You can still get quite far by cleverly parsing html as text though.

But building a DOM tree, not possible…

We announced an open beta for a natively-implemented streaming HTML parser today: https://blog.cloudflare.com/html-rewriter-beta/

That said, it is not a DOM-based parser, since building a DOM would require parsing everything up front. It may suffice for your use case, depending on what you need to accomplish.

4 Likes

That’s super amazing news! Thanks, Harris, for letting me know! Was about to start writting my own HTML parser in rust/wasm, as https://github.com/kuchiki-rs/kuchiki compiled to wasm tas just too slow on workers.

What library are you using behind the scenes for HTMLRewriter?

1 Like

A new one, developed in house. I’m hesitant to reveal anything more because I don’t want to steal the author’s thunder – we’ll have an in-depth technical blog post on it going out soon.

5 Likes