Hi,
Is it possible to add a script attribute after processing the content text inside the script tag with HTML Rewriter API?
[Cloudflare Workers](Sample Playground Code)
I am adding a sample code which I have written so far with some random string check for script body and adding script attribute based on that check. But this doesn’t seem to work,
This content token is no longer valid. Content tokens are only valid during the execution of the relevant content handler.
at addNonce (worker.js:40)
at ElementHandler.text (worker.js:30
Currently I am using regex (which is a lot heavier operation) to extract the script body and add attributes to script tag. If HTML ReWriter API works for my use case then it will improve the performance of my worker manyfolds.