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 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;