Lazy Loaded Prefill Embeds
CodePen's standard Embedded Pens require the Pen to exist on CodePen before it can be dropped onto another site. The company's Prefill Embeds do away with that step: the code and settings for the embed are supplied through code blocks already sitting on the page, following a progressive enhancement approach, and the Pen never has to live on CodePen at all. That lets the code stay in a Git repo or a database, which can offer a more desirable level of control.
Stephen Shaw wrote up a technique for creating these Prefill Embeds on demand, triggered by user interaction — for example, a "Run this code" button — so the embed is only present when a user wants to see it. It is a very lightweight method for adding optional interactivity to a blog post or documentation page.
The original article demonstrates the idea with an example embedded directly in the post. All of the code for it lives in the page itself, and the Embedded Pen iframe does not load until a reader clicks to load it — which they would do only if they wanted to see that code run.



