Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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.

HTML

              
                <p style="margin-bottom: 1000px;">Please scroll down. The image is below the viewport.</p>
<p style="margin-bottom: 1000px;">Way to go&hellip;</p>

<h4>Lazy cat loaded lazily</h4>
<p>If your browser supports native lazy-loading, it loads the first 2 kB of the image in order to display a placeholder. Then, it loads the full-size image.</p>
<p>If your browser does not support native lazy-loading, it loads the lazysizes library and sets the <code>img</code>'s <code>src</code> to a low-quality image placeholder, which is also around 2 kB in size. Then, it loads the full-size image.</p>
<div class="alert alert-warning">The native lazy-loading's 2 kB range request do not work from within Codepen. However, you can make this work by copying this to an empty HTML file on your computer.</div>
<img data-src="https://demo.tiny.pictures/native-lazy-loading/lazy-cat.jpg?width=500" data-lqip="https://demo.tiny.pictures/native-lazy-loading/lazy-cat.jpg?width=500&blur=5&quality=10" loading="lazy" alt="Lazy cat loaded lazily">

<script>
  const images = document.querySelectorAll("img[loading='lazy']")
  if ("loading" in HTMLImageElement.prototype) {
    // native lazy-loading supported
    for (const image of images) {
      image.src = image.dataset.src
    }
  } else {
    // native lazy-loading not supported
    // dynamically load the lazysizes library
    import("https://cdnjs.cloudflare.com/ajax/libs/lazysizes/4.1.5/lazysizes.min.js")
    for (const image of images) {
      // request the low-quality image placeholder
      image.src = image.dataset.lqip
      // enable lazy-loading when user scrolls image into view or browser is idle
      image.classList.add("lazyload")
    }
  }
</script>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console