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

              
                <h1>Webkit style recalc bug</h1>
<p>Webkit seems to have a nasty bug that causes <strong>MAJOR</strong> slowdowns if you merely read a property from the calculated style after setting an inline value on a completely different element altogether, even of the property doesn't affect document flow at all (<code>WebkitTransform</code> in this case). It forces a style recalc but it really shouldn't. Or am I missing something? 
  
  
  When you click "run test" below, we'll loop through all the letters, <code>getCalculatedStyle()</code> on each one, and then set the <code>style.WebkitTransform</code> to a random offset. Watch how much longer it takes if you select "Read transform before setting"! I know it'll go faster if all of the reading happens first, and then all of the setting, but that shouldn't be necessary.</p>
<label style="color:red"><input type="checkbox" id="read" /> Read transform before setting</label><br> <button>RUN TEST</button>
<div id="time"></div>
<div id="container"></div>
              
            
!

CSS

              
                body {
  background-color: black;
  color: #ccc;
  font-family: sans-serif;
}
h1 {
  color: white;
  font-weight: normal;
}
#container {
  font-size:25px;
  color: #555;
  margin-top: 15px;
}
div {
  display:inline-block;
  position:relative;
}
button {
  font-size: 20px;
  padding: 10px;
}
              
            
!

JS

              
                var letters = "abcdefghijklmnopqrstuvwxyz",
    i = 2000, //number of letters (increase to add stress)
    container = document.getElementById("container"),
    content = [],
    div;

//create a bunch of DIVs with a random letter in each...
while (--i > -1) {
  div = document.createElement("div");
  container.appendChild(div);
  div.innerHTML = letters.charAt(getRandomInt(0,26));
  content.push(div);
}

$("button").click(function() {
  var time = Date.now(),
      i = content.length,
      read = $("#read").prop("checked"),
      newValue = "translate(" + getRandomInt(0, 100) + "px," + getRandomInt(0, 100) + "px)",
      computedStyle,
      currentTransform;
  while (--i > -1) {
    computedStyle = document.defaultView.getComputedStyle(content[i]);
    if (read) { //LOOK HOW MUCH LONGER THIS TAKES (and we're not really doing anything except reading a property)
      currentTransform = computedStyle.WebkitTransform;
    }
    content[i].style.WebkitTransform = newValue;
  }
  $("#time").text("took " + (Date.now() - time) + "ms");
});

function getRandomInt(min, max) {
  return Math.round(min + (Math.random() * (max - min)));
}

              
            
!
999px

Console