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.


                <!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" />
    <title>Throttling Example</title>
    <link rel="stylesheet" href="style.css" />

    <button id="btn" onclick="normalFunc(); apiWithThrottle();">Click Me!</button>
    <div class="first"><label>
      Number of times the button is clicked :
    <input type="text" id="countClicks" value="0"></input></div>
    <div clas="second">
        Number of times the API call will be made :
      <input type="text" id="countCalls" value="0"></input>
    <script src="script.js"></script>



                body {
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;

div {
  padding: 15px;

button {
  margin-top: 20px;
  padding: 10px;
  width: 150px;
  font-size: 18px;

input {
  width: 30px;
  font-size: 20px;
  /* border: none; */

.first {
  margin-top: 20px;



                var btn = document.getElementById("btn"); // Query Selector for the Button

let i = 1; // To track number of Clicks on the Button
let j = 1; // To track number of API calls being made

// Normal Function which increments number of clicks
// Called on Clicking the Button
const normalFunc = () => {
  document.getElementById("countClicks").value = i++;
  console.count("Normal Function Call");

// Function to be throttled (API calls)
const apiCallFunc = () => {
  document.getElementById("countCalls").value = j++;
  console.count("Throttled Function");

// The Throttle Function
const throttle = (fn, limit) => {
  let flag = true;
  return function () {
    if (flag) {
      flag = false;
      setTimeout(() => {
        flag = true;
      }, limit);

// Called on clicking the Button
const apiWithThrottle = throttle(apiCallFunc, 1000);