Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <!--
1. You need to add this div anywhere inside the body tag of your site:
-->
<div id="preloader"></div>

<!--
2. If your site doesn't already use jquery, add this script tag inside the head of your site:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>

-->
    
<h1>Super Simple Full-Page Preloader</h1>
    
<p>Did you see the preloader? if not, re-load and watch the center of the screen below.  You should see a pac-man animation until the site loads (which will be quick because there's not much to load).</p>

<p>This preloader was created to be as easy to impliment as possible, it should work on any site regardless of what CMS you are using.</p>

<p>Since writing this code it's been viewed around 300,000 times on codepen!  I'm celebrating this milestone by re-writing the code and comments to make it even easier to use!</p>

<p>If you didn't see the preloader, add more content (big images) so the page takes longer to load</p>

<p>If you use this code on your site, please consider supporting us with a BTC tip to this address:</p>
 <p>bc1q8xftqu2xjryslnpt9hdy7qngz938hpmmzjtwvm
</p>
              
            
!

CSS

              
                /* add this css to your stylesheet or add it within a style tag in the head of your document */

.js div#preloader {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 999;
  width: 100%;
  height: 100%;
  overflow: visible;
  
  /* You can change the background color and image URL here.  This solution works with animated .svg and animated .gif */
  background: #ffffff url('https://gist.githubusercontent.com/condensed-io/d4da34ecfdeda137ad4787fbd244ed27/raw/b96d939e9baf98ff79394c11af83c10a6acdd241/pac.svg') no-repeat center center;
}
              
            
!

JS

              
                // add the javascript below to the head of your doc inside a script tag

// this line adds a class of js to your html element, we add the class with javascript instead of just putting it in the html so if javascript isn't available, the preloader does not show up, because without javascript it won't fade out and would just be there forever.
document.documentElement.classList.add("js");

// dom is loaded
jQuery(document).ready(function($) {  
// fade out preloader
$('#preloader').fadeOut('slow',function(){$(this).remove();});

});
              
            
!
999px

Console