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

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

              
                <h1>User Timing API (Demo)</h1>
<form>
  <div class="field-wrapper">
    <label for="count-ut-1">Test 1: Count until</label>
    <input type="number" id="count-ut-1" value="100000" />
  </div>

  <div class="field-wrapper">
    <label for="count-ut-2">Test 2: Count until</label>
    <input type="number" id="count-ut-2" value="1000000" />
  </div>

  <button type="button" id="button-play-ut" class="button-demo">Run demo</button>
</form>
<span id="ut-unsupported" class="hidden">API not supported</span>
<div id="ut-results" class="hidden">
  <h2>Marks</h2>
  <div id="ut-marks"></div>
  <h2>Measures</h2>
  <div id="ut-measures"></div>
</div>

<p class="c"><small>By Aurelio De Rosa. <a href="https://github.com/AurelioDeRosa/HTML5-API-demos">HTML5 API Demos</a>.</small></p>
              
            
!

CSS

              
                * {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
   box-sizing: border-box;
}

body {
  max-width: 500px;
  margin: 2em auto;
  padding: 0 0.5em;
  font-size: 20px;
}

.c {
  text-align: center;
}

h1 {
  text-align: center;
  font-size: 1.5em;
}

.hidden {
  display: none;
}

.field-wrapper {
  margin-bottom: 1em;
}

.button-demo {
  padding: 0.5em;
  display: block;
  margin: 1em auto;
}
              
            
!

JS

              
                window.performance = window.performance || {};
if (performance.mark === undefined) {
  document.getElementById('ut-unsupported').classList.remove('hidden');
  document.getElementById('button-play-ut').setAttribute('disabled', 'disabled');
} else {
  document.getElementById('button-play-ut').addEventListener('click', function() {
    var i;
    var perfMarks;
    var perfMeasures;

    document.getElementById('ut-results').classList.remove('hidden');
    // A time consuming function
    performance.mark('startTime1');
    for(i = 0; i < parseInt(document.getElementById('count-ut-1').value); i++);
    performance.mark('endTime1');

    // Another time consuming function
    performance.mark('startTime2');
    for(i = 0; i < parseInt(document.getElementById('count-ut-2').value); i++);
    performance.mark('endTime2');

    performance.measure('durationTime1', 'startTime1', 'endTime1');
    performance.measure('durationTime2', 'startTime2', 'endTime2');
    performance.measure('durationTimeTotal', 'startTime1', 'endTime2');

    // Print marks
    perfMarks = performance.getEntriesByType('mark');
    document.getElementById('ut-marks').innerHTML = '';
    for (i = 0; i < perfMarks.length; i++) {
      document.getElementById('ut-marks').innerHTML +=
        'Name: ' + perfMarks[i].name + ' - ' +
        'Start Time: ' + perfMarks[i].startTime + '<br />';
    }

    // Print measures
    perfMeasures = performance.getEntriesByType('measure');
    document.getElementById('ut-measures').innerHTML = '';
    for (i = 0; i < perfMeasures.length; i++) {
      document.getElementById('ut-measures').innerHTML +=
        'Name: ' + perfMeasures[i].name + ' - ' +
        'Duration: ' + perfMeasures[i].duration + '<br />';
    }
    performance.clearMarks();
    performance.clearMeasures();
  });
}

              
            
!
999px

Console