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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <h3 id="status"></h3>
<textarea id="comment"></textarea>
              #comment {
  height: 100px;
  width: 500px;

body {
  background-color: #eee;

$(document).ready(function () {
  // Invoke our plugin and get reference to the returned API object.
  var autosaveApi = $('#comment').autosave({
    // Pass in our own custom save URL.
    saveUrl: '',
    // Pass in a callback to be invoked whenever the status changes.
    statusChanged: function (status) {
      $('#status').text(status.text).css('color', status.color);
  // Use the autosave API to query for the initial saved status and set our label.
  var initialStatus = autosaveApi.getStatus();
  $('#status').text(initialStatus.text).css('color', initialStatus.color);

// -=-=-= AUTOSAVE PLUGIN =-=-=-

// Create a self-invoking function to preserve the jQuery dollar sign.
(function ($) {
  // Create the autosave plugin.
  $.fn.autosave = function (userOptions) {
    var $textarea = this;
    window.$textarea = this;
    // Setup our plugin's default options.
    var defaultOptions = {
      saveUrl: null,
      status: {
        text: 'no changes',
        color: '#009'
      statusChanged: null
    // Override default options with any provided by user.
    var options = $.extend({}, defaultOptions, userOptions);
    // Create a function to save the user's content.
    var save = function () {
      // Make a call to our server endpoint to save the user's text.
        url: options.saveUrl,
        type: 'POST',
        data: { content: $textarea.val() },
        // If successful then change the save status and invoke the user's callback.
        success: function () {
          options.status = {
            text: 'saved',
            color: '#090'
          if (options.statusChanged) {
        // If an error occurred then change the save status and invoke the user's callback.
        error: function () {
          options.status = {
            text: 'error saving',
            color: '#f00'
          if (options.statusChanged) {
    // Create a variable to track our timeout ID.
    var timeoutId;
    // Setup an event handler to listen for keyup events in the textarea.
    $textarea.keyup(function (e) {
      // If we have a timeoutId then use it to clear the existing timeout.
      if (timeoutId) {
      // Set our saved status.
      options.status = {
        text: 'pending save...',
        color: '#770'
      if (options.statusChanged) {
      // Start a new timeout that will save the user's content in 3/4 of a second.
      // If they type again this function will run, clear the timeout, and start a new one.
      // If they stop typing for 750 milliseconds then the timeout will finally fire and save.
      timeoutId = setTimeout(save, 750);
    return {
      getStatus: function () {
        return options.status;
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.