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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


                <h3>SVG path (red) versus canvas path (black) performance</h3>
<p>This test draws 100 - 5000 bars using both APIs and measures the inter-frame timings.</p>
<p>Results are shown on a linear axis, bar count increases left-to-right.</p>
<p>Solid triangle indicates testing in progress.</p>

<svg width="640" height="480">

<canvas width="640" height="480"></canvas>



                body {
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;

svg, canvas {
  position: absolute;
  top: 25px;
  left: 25px;
  opacity: 0.5;

canvas {
  left: 30px;

path {
  stroke: red;


                const select =;
const range = d3_array.range;
const extent = d3_array.extent;
const linear = d3_scale.scaleLinear;
const barGenerator =;

const render = (svgData, canvasData) => 
  new Promise((resolve, reject) => {
    const timings = {
      count: svgData.length

    const x = linear()
      .range([10, 630])
      .domain(extent(svgData, (d, i) => i));

    const y = linear()
      .range([470, 10])
      .domain(extent(svgData, (d, i) => d));

    const path = select('svg')

    const svgBar = barGenerator()
      .x((d, i) => x(i))
      .y((d) => y(d))
      .height((d) => y(0) - y(d))

    timings.startSvg =;
    path.attr('d', svgBar);
    requestAnimationFrame(() => {
      timings.endSvg =;

      const canvas = document.querySelector('canvas');

      const ctx = canvas.getContext('2d');

      const canvasBar = barGenerator()
        .x((d, i) => x(i))
        .y((d) => y(d))
        .height((d) => y(0) - y(d))

      timings.startCanvas =;
      canvas.width = canvas.width;
      requestAnimationFrame(() => {
        timings.endCanvas =;

let promise = Promise.resolve();
let results = [];
const recordResults = (results, timings) => 
  [...results, {
    count: timings.count,
    canvas: timings.endCanvas - timings.startCanvas,
    svg: timings.endSvg - timings.startSvg
for (let i = 100; i <= 5000; i+=100) {
  promise = promise.then((timings) => {
    if (timings) {
      results = recordResults(results, timings);
    const data = range(0, i)
    return render(data, data);
promise.then((timings) => {
  results = recordResults(results, timings);
  render( => d.svg), => d.canvas));