Skip to content
373: Script Injection with Cloudflare Workers episode artwork

EPISODE · Jun 22, 2022

373: Script Injection with Cloudflare Workers

from CodePen Radio · host CodePen Blog

This week Shaw and Chris dig into some deepnerd tech stuff: manipulating HTML. In a perfect world, perhaps we wouldn't need to, but today, and even moreso in the foreseeable future of CodePen, we need to do a smidge of HTML manipulation on the HTML that you write or that is generated by code you write on CodePen. A tiny example is removing the autofocus attribute when a Pen in shown in a grid view <iframe>. A more significant example is that we need to inject some of our own JavaScript into your Pen, to power features of CodePen itself, like the console, which receives information from your rendered page (like logs, errors, etc) and can push commands to execute as well. So how do we inject a <script> into absolutely 100% arbitrary HTML? Well, it's tricky. We're starting to do it with Cloudflare Workers and the HTMLRewriter stuff they can do. Even then, it's not particularly easy, with lots of edge cases. Thank gosh for Miniflare for the ability to work on this stuff locally and write tests for it. Time Jumps

Episode metadata supplied by the publisher feed · Published Jun 22, 2022

Embed this episode

Ready to play

373: Script Injection with Cloudflare Workers

0:00 0:00

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

No similar episodes found.

No similar podcasts found.

Frequently Asked Questions

When was this CodePen Radio episode published?

This episode was published on June 22, 2022.

Can I download this CodePen Radio episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.
URL copied to clipboard!