Pen Settings



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


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.


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.


                No debouncing : <input onkeyup="callSomeApi()" />
0.5 seconds debouncing : <input onkeyup="callSomeApiDebounced()" />




                // check the console for results

let numberOfApiCallsMade = 0;

const callSomeApi = () => {

const debounce = (fn, delay) => {
  let timer;
  // return an anomymous function that debounces the function (forces a function to wait a certain amount of time before running again)
  // That also sounds like throttling but debouncing a functon call resets the timer everytime the function is called
  return () => { 
    // this is the callSomeApiDebounced function
    // uses closure
    // reset the timer to set it again
    /** storing the timer so that it can be reset everytime the function is called. 
    if the function is called again before the previous call's setTimeout was completed, the previous call's timer is removed and new call's
    timer is set **/
    timer = setTimeout(fn, delay) 

const callSomeApiDebounced = debounce(callSomeApi, 500);


function debounce(fn, delay) {
  let timer = null;
  return (input) => {
    timer = setTimeout(() => fn(input), delay);
    // not like so : timer = setTimeout((input) => fn(input), delay);

const someFn = (num) => console.log(num);
const debouncedFn = debounce(someFn, 1000);