cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <h1>Improving Web Font Performance with Local Storage (Demo)</h1>

<p>I am speaking on literary criticism, and in the world in which we are actually living that is almost as unpromising as speaking about peace. This is not a peaceful age, and it is not a critical age. In the Europe of the last ten years literary criticism of the older kind — criticism that is really judicious, scrupulous, fair-minded, treating a work of art as a thing of value in itself — has been next door to impossible.</p>

<p class="p">Demo by Luis Vieira. <a href="http://www.sitepoint.com/improving-font-performance-subsetting-local-storage/" target="_blank">See article</a> (publishing April 7, 2015).</p>
            
          
!
            
              body {
  text-align: center;
  line-height: 1.5;
  padding: 0 30px;
}

.fallback {
  font-family: 'Georgia', serif;
  line-height: 1.7em;
  letter-spacing: 1px;
  font-size: 15px;
}

.webFont {
  font-family: 'vollkornregular', serif;
  line-height: 1.6em;
  letter-spacing: 1px;
  font-size: 16px;
}

p {
  text-align: left;
}

.p {
  padding-top: 100px;
  text-align: center;
  font-size: 14px;
}
            
          
!
            
              (function () {
  'use strict';
  document.documentElement.className = 'fallback';
  var css_href = 'https://codepen.io/SitePoint/pen/6c6dc49b39b410083cd30ac1f16be2fa.css';
  var localStorageSupported = function() {
    try {
      localStorage.setItem('test', 'test');
      localStorage.removeItem('test');
      return true;
    } catch(e) {
      return false;
    }
  }

  if (localStorageSupported() && localStorage.spdemowebFonts) {
    injectRawStyle(localStorage.getItem('spdemowebFonts'));
  } else {
    window.onload = function() {
      injectFontsStylesheet();
    }
  }

  function injectFontsStylesheet() {
    var xhr = new XMLHttpRequest();
      xhr.open('GET', css_href, true);
      xhr.onreadystatechange = function() {
        if (xhr.readyState === 4) {
          injectRawStyle(xhr.responseText);
          localStorage.setItem('spdemowebFonts', xhr.responseText);
        }
      }
    xhr.send();
  }

  function injectRawStyle(text) {
    var style = document.createElement('style');
    style.innerHTML = text;
    document.getElementsByTagName('head')[0].appendChild(style);
    document.documentElement.className = 'webFont';
  }
}());
            
          
!
999px
Loading ..................

Console