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

              
                <div>
  <input type="button" value="非同期で重い処理" id="heavy">
  <input type="button" value="単純処理" id="simple">
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                window.CP.PenTimer.MAX_TIME_IN_LOOP_WO_EXIT = 20000;

async function heavyProc(){
  // awaitがないとheavyProcは非同期にならないので1ms非同期処理を待つ処理を追加
  await new Promise(resolve => setTimeout(resolve, 1));
  console.log('start heavyProc:' + Date.now());
  
  const now = Date.now();
  // 同期的に10秒間待つ処理
  while(Date.now() - now < 10000){}
  console.log('end heavyProc:' + Date.now());
}

document.getElementById('heavy').addEventListener('click',function(){
  console.log('start clickHeavy:' + Date.now());
  const proc = heavyProc();
  console.log('end clickHeavy:' + Date.now());
});

document.getElementById('simple').addEventListener('click', function(){
  console.log('clickSimple:' + Date.now());
});
              
            
!
999px

Console