Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <script id="worker" type="text/javascript-worker">
  self.addEventListener('message', async event => {
    const imageURL =

    const response = await fetch(imageURL)
    const blob = await response.blob()

    // Send the image data to the UI thread!
      imageURL: imageURL,
      blob: blob,

  <img data-src="">
  <img data-src="">
  <img data-src="">
  <img data-src="">
  <img data-src="">
  <img data-src="">



                body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-height: 100vh;
  max-width: 100vw;

img {
  max-width: 100%;


 * main.js

// This is a workaround because Codepen was having some issues loading the
// JavaScript file from a separate pen. 🤷
const workerAsText = document.querySelector('#worker').textContent
const workerAsBlob = new Blob([workerAsText], { type: 'text/javascript' })
const ImageLoaderWorker = new Worker(URL.createObjectURL(workerAsBlob))

// This is how we would *normally* load the web worker
// const ImageLoaderWorker = new Worker('')

const imgElements = document.querySelectorAll('img[data-src]')

ImageLoaderWorker.addEventListener('message', event => {
  // Grab the message data from the event
  const imageData =

  console.log('We got a message back!', imageData)

  const imageElement = document.querySelector(`img[data-src='${imageData.imageURL}']`)

  const objectURL = URL.createObjectURL(imageData.blob)
  imageElement.setAttribute('src', objectURL)

imgElements.forEach(imageElement => {
  const imageURL = imageElement.getAttribute('data-src')