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 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

              
                <div class="grid">
    <p>Compressed Size: <i class="size">Waiting</i></p>
    <p>Build Time: <i class="time">Waiting</i></p>
    <button class="btn">Compress (Ctrl+Enter)</button>
</div>
<div class="lorem" contenteditable>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent sed tristique lacus. Duis leo arcu, auctor in mattis et, accumsan eget nisl. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi venenatis euismod quam, eu rutrum eros pellentesque quis. Integer imperdiet semper dignissim. Integer efficitur nisi at augue tempus porta. In in gravida dui. Sed ac diam erat. Quisque varius mauris vel ipsum blandit, vel congue lectus elementum. Etiam consectetur mi purus, ut semper magna aliquet quis. Nunc congue dignissim est, non malesuada felis aliquet id. Donec at neque ac enim imperdiet convallis. Curabitur tincidunt dapibus metus non tempor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus vitae gravida enim. Sed lacinia lacus massa, ac mattis felis accumsan et.

    Integer lobortis sapien quis mi cursus ornare. Mauris lacinia justo eu eleifend ornare. Vivamus efficitur augue vitae nunc euismod, sed feugiat nunc pharetra. Praesent non sem tellus. Donec id felis non purus vulputate feugiat at nec ante. Suspendisse condimentum justo sem, vel vehicula mauris pulvinar id. Phasellus risus ex, venenatis sed bibendum eu, faucibus quis ipsum. Curabitur suscipit quis massa et dignissim. Nunc ac odio mauris. Duis turpis lectus, tempus dapibus ante vel, pharetra malesuada turpis. Aenean feugiat tellus eu mi fringilla, in pulvinar diam vulputate. Mauris lobortis neque eu nibh tempor, eget pharetra massa consectetur. Etiam luctus mauris a ligula convallis tincidunt. Praesent fringilla cursus est, sit amet vehicula dui facilisis et. Mauris a metus elit.

    Vestibulum pellentesque, enim ac vulputate commodo, risus urna ultrices mauris, eget euismod odio libero et eros. Integer faucibus orci sed imperdiet rhoncus. Proin eros eros, ornare ut gravida et, ultrices sed elit. Vestibulum magna neque, lobortis id auctor eu, malesuada non est. Aliquam faucibus a dolor sit amet placerat. Morbi malesuada leo elit. Maecenas tempor dapibus dapibus. Sed ultricies dapibus nisi et rutrum. Vivamus ipsum eros, tincidunt ut enim at, finibus condimentum neque. Nullam sit amet diam eu ipsum tristique sollicitudin. Sed facilisis lectus est, eget mattis erat aliquet et. Cras sed urna volutpat, consequat velit sed, elementum eros. In vel nibh quis sapien mollis fermentum.

    Vestibulum non iaculis velit. Vestibulum fermentum eros non massa dignissim, fermentum feugiat nunc congue. Vestibulum pulvinar augue eget tempus congue. Aliquam maximus elementum diam. Ut sit amet porttitor risus. In hac habitasse platea dictumst. Suspendisse a viverra odio, et hendrerit dolor. Suspendisse nec suscipit nibh.

    Phasellus quis odio ex. Ut pharetra dapibus nisi, et dapibus orci eleifend sed. Aliquam sit amet commodo orci. Duis faucibus, risus quis sagittis finibus, magna nunc accumsan sapien, ac tincidunt mauris odio fermentum ex. Nunc sed justo ipsum. Nullam viverra ante ac lorem facilisis, ac sodales velit iaculis. Donec nec urna ipsum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque lacinia molestie aliquet. Donec eget felis in leo auctor tincidunt.

    Generated 5 paragraphs, 473 words, 3187 bytes of Lorem Ipsum.</div>
              
            
!

CSS

              
                @media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

.grid,
.lorem {
    padding: 10px;
}

.grid {
    display: grid;
    gap: 10px;
    font-variant-numeric: tabular-nums;
    grid-auto-flow: column;
    justify-content: space-around;
}

.lorem {
    border: 1px solid;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 8px 12px;
    margin: 10px;
    resize: both;
    height: 500px;
    overflow: auto;
    scrollbar-gutter: stable;
}

              
            
!

JS

              
                import prettyBytes from "https://cdn.skypack.dev/pretty-bytes?min";
import {
    gzipSync,
    strToU8,
    compress
} from "https://cdn.skypack.dev/fflate?min";

let timeFormatter = new Intl.RelativeTimeFormat("en", {
    style: "narrow",
    numeric: "auto"
});

let content = document.querySelector(".lorem");
let time = document.querySelector(".time");
let size = document.querySelector(".size");

let asyncCompress = (buf, opts = {}) => {
    return new Promise((resolve, reject) => {
        // The default compression method is gzip
        // Increasing mem may increase performance at the cost of memory
        // The mem ranges from 0 to 12, where 4 is the default
        compress(buf, opts, (err, data) => {
            if (err) reject(err);
            resolve(data);
        });
    });
};

let compressFn = () => {
    const startTime = Date.now();
    const buf = strToU8(content.textContent.trim());
    const timeout = setTimeout(() => {
        time.textContent = "Loading...";
        size.textContent = "Loading...";
    }, 100);

    (async () => {
        const data = await asyncCompress(buf, { level: 9 });
        const gzipSize = prettyBytes(data.length);
        clearTimeout(timeout);

        time.textContent = timeFormatter.format(
            (Date.now() - startTime) / 1000,
            "seconds"
        );
        size.textContent = gzipSize;
        console.log(gzipSize);
    })();
};

compressFn();

let button = document.querySelector(".btn");
button.addEventListener("click", compressFn);
document.addEventListener("keydown", (e) => {
    if (e.ctrlKey && e.keyCode === 13) {
        compressFn();
    }
});

              
            
!
999px

Console