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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

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

Packages

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.

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

              
                <main>
  <h1>Lazy Instagram Embed <b>Gonna&nbsp;Be&nbsp;Lazy</b></h1>

  <p>Donec sed odio dui. Aenean lacinia bibendum nulla sed consectetur. Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Lorem ipsum dolor sit amet, consectetur adipiscing</p>

  <p>Maecenas faucibus mollis interdum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. Vestibulum id ligula porta felis euismod semper.</p>

  <p>Maecenas sed diam eget risus varius blandit sit amet non magna. Nullam quis risus eget urna mollis ornare vel eu leo. Donec ullamcorper nulla non metus auctor fringilla. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Curabitur blandit tempus porttitor. Donec ullamcorper nulla non metus auctor fringilla.</p>

  <p>Maecenas sed diam eget risus varius blandit sit amet non magna. Nullam quis risus eget urna mollis ornare vel eu leo. Donec ullamcorper nulla non metus auctor fringilla. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Curabitur blandit tempus porttitor. Donec ullamcorper nulla non metus auctor fringilla.</p>

  <p>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Donec sed odio dui. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>

  <p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p>

  <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</p>

  <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</p>

  <p>Maecenas faucibus mollis interdum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam id dolor id nibh ultricies vehicula ut id elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>

  <p>Maecenas faucibus mollis interdum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam id dolor id nibh ultricies vehicula ut id elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>

  <hr/>
  
  <iframe allowtransparency="true" frameborder="0" height="710" scrolling="no" data-src="//instagram.com/p/BCudaCREZvf/embed/" width="612" class="lazyload"></iframe>

  <hr/>
  
  <p>Maecenas faucibus mollis interdum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam id dolor id nibh ultricies vehicula ut id elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>

    <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</p>

  <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.</p>

  <p>Maecenas faucibus mollis interdum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam id dolor id nibh ultricies vehicula ut id elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>

  <hr/>
  
  <iframe allowtransparency="true" frameborder="0" height="710" scrolling="no" data-src="//instagram.com/p/zkOqETkZjI/embed/" width="612" class="lazyload"></iframe>

  <hr/>
  
  <p>Maecenas faucibus mollis interdum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam id dolor id nibh ultricies vehicula ut id elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>

 
  <p>Maecenas faucibus mollis interdum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Nullam id dolor id nibh ultricies vehicula ut id elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>

</main>
              
            
!

CSS

              
                /* Demo Styles */
html {
  box-sizing: border-box;
  font:1.2em/1.5 'Lato', sans-serif;
  width: 100%;
  height: 100%;
  padding: 2em;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  text-align: left;
  background-color: #1D1F20;
  color: #777;
}

h1, h2, h3 {
  color: #efefef;
  line-height: 1.2;
  margin-bottom: 1.5em;
  b {
    color: skyblue;
  }
}

a,
a:visited {
  color: white;
}

main {
  max-width: 1100px;
  margin: auto;
  background-color: #111;
  padding:3em;
}

hr {
  margin: 2em 0;
  border-color: #333;
}

/* Instagram Embed */
iframe[data-src*="instagram.com"], iframe[src*="instagram.com"] {
  display: block;
  margin: 3em auto;
  box-shadow: 0 0 3px #ccc;
}

              
            
!

JS

              
                // Responsive LazyLoaded Intagram Embed.
// Loads the embed, but lazyily.
// Maintains aspect ratio of the embed across varying widths
// Based on codepen/ryanburnette's orignal jQuery plugin
// https://github.com/ryanburnette/responsive-instagram
// But this is vanilla JS and...has some other features.

window.responsiveIframes = {
    defaults: {
        width: 610,
        extraHeight: 80,
        breakpoint: 620,
        fullWidth: true, // If true, iFrame will always have a width of 100% until it reaches maxWidth
        maxWidth: 800, // Only works when fullWidth is true. Sets CSS max-width to this value.
        src: ['instagram.com'],
        lazysizes: true // Compatible with lazysizes
    },

    options: {},
    frames: [],
    initialized: false,

    init: function(param_options) {
        this.frames = [];

        if (arguments.length === 1 && typeof param_options === 'object') {
            this.options = this.helpers.extend(this.defaults, param_options);
        } else {
            this.options = this.helpers.extend(this.defaults, {});
        }

        this.initialized = true;

        // Attach listeners to resize iFrame with window.
        window.addEventListener("load", function() {
            window.responsiveIframes.resizeFrames();
        });
        window.addEventListener("resize", function() {
            window.responsiveIframes.resizeFrames();
        });

    },
    resizeFrames: function() {
        if (!this.initialized) {
            this.init();
        }

        if (this.frames.length === 0) {
            this.frames = this.helpers.getIframes(this.options.src);
        }

        for (var i = 0; i < this.frames.length; i++) {
            this.resizeFrame(this.frames[i]);
        }
    },
    resizeFrame: function(elem) {
        var width;
        var windowWidth = this.helpers.windowWidth();
        var newHeight;

        if (this.options.fullWidth) {
            elem.style.width = '100%';
            elem.style.maxWidth = this.options.maxWidth + 'px';
        } else {
            if (windowWidth <= this.options.breakpoint) {
                elem.style.width = '100%';
            } else {
                elem.style.width = this.options.width.toString(10) + 'px';
            }
        }

        width = elem.offsetWidth;

        newHeight = Math.round(width + this.options.extraHeight);
        elem.style.height = newHeight.toString(10) + 'px';
    },
    helpers: {
        windowWidth: function() {
            var docElemProp = window.document.documentElement.clientWidth;
            var body = window.document.body;
            return window.document.compatMode === "CSS1Compat" && docElemProp || body && body.clientWidth || docElemProp;
        },
        extend: function(obj, extObj) {
            if (arguments.length > 2) {
                for (var a = 1; a < arguments.length; a++) {
                    this.extend2(obj, arguments[a]);
                }
            } else {
                for (var i in extObj) {
                    obj[i] = extObj[i];
                }
            }
            return obj;
        },
        getInstagramIframes: function() {
            var matchingElements = [];
            var allElements = document.getElementsByTagName('iframe');

            for (var i = 0; i < allElements.length; i++) {
                var src = allElements[i].getAttribute('src');
                if (src !== null && src.indexOf('instagram.com') !== -1) {
                    matchingElements.push(allElements[i]);
                }
            }

            return matchingElements;
        },
        getIframes: function(param_src) {
            var matchingElements = [];
            var allElements = document.getElementsByTagName('iframe');

            for (var i = 0; i < allElements.length; i++) {
                var src = allElements[i].getAttribute('src');

                if (src === null || (typeof src === 'string' && src.length === 0)) {
                    src = allElements[i].getAttribute('data-src');
                }

                if (src !== null) {
                    if (Array.isArray(param_src)) {
                        for (var j = 0; j < param_src.length; j++) {
                            if (src.indexOf(param_src[j]) !== -1) {
                                matchingElements.push(allElements[i]);
                            }
                        }
                    } else {
                        if (src.indexOf(param_src) !== -1) {
                            matchingElements.push(allElements[i]);
                        }
                    }
                }
            }

            return matchingElements;
        }
    }

};

// Single domain example
// window.responsiveIframes.init({src: 'instagram.com'});

// Multi-domains example
// window.responsiveIframes.init({
// src: ['instagram.com', 'youtube.com'],
// fullWidth: true,
// maxWidth: 900
// });

window.responsiveIframes.init();

// EOF
              
            
!
999px

Console