Categories
Rant WordPress Writings

How to Disable Autosave in WordPress

The autosave feature in recent versions of WordPress (versions 2.5–2.7) is actually a misfeature:

… A misfeature is not a bug. Nor is it a simple unforeseen side effect; the term implies that the feature in question was carefully planned, but its long-term consequences were not accurately or adequately predicted (which is quite different from not having thought ahead at all).

The improper functioning of the WordPress autosave has bitten me several times. It’s supposed to prevent you from losing work by periodically saving your blog edits in the background, when in fact it has caused me to lose work by its very operation.

[WordPress Logo Inverted]

Basically, the most recent edits made to a blog entry often get dropped when you go to “Preview” or “Publish” the entry. In other words, during either of these two operations, it reverts you to what it had autosaved in the past and the new edits are lost. The frustrating thing is that most users would expect the “Preview” operation if not the “Publish” operation to properly save what’s in the edit box. So often, you might end up publishing an incomplete or incorrect version of your blog entry without even knowing it.

This is madness. Let’s stop it.

Find the following four files in the wp-admin/ directory of your WordPress installation:

  1. page-new.php
  2. page.php
  3. post-new.php
  4. post.php

and comment out the following line:

wp_enqueue_script('autosave')

by changing it to:

//wp_enqueue_script('autosave')

This will disable the autosave feature in the WordPress user interface.

A secondary part of the solution, too, is to always hit “Save Draft” before hitting “Preview”. I’m not sure if this is strictly necessary, but now I’m paranoid.

Thanks to Allen Day and William Lone for showing me how to do this.

6 replies on “How to Disable Autosave in WordPress”

Hmm. I’ve just tried this and it’s broken the “Preview Changes” button when editing already-published posts or pages. This is on WP 2.8

@Jonathan you would need to manually save the post as a draft before you can preview it. This is because the auto save puts your current content into the database as a draft. Without the autosave on, you have to manually tell the information to be put into the database by saving it as a draft.

I totally agree with the nusiance of the function. I always have the page being edited open in a browser. I make my edits then press “UPDATE” I go the the opened page, hit refresh and view my changes. This seems to me to be the best way to view the published page. I have been bitten for various reasons thinking that preview was a valid change.

I’m grateful that tabbed surfing is in vogue.

Leave a Reply

Your email address will not be published. Required fields are marked *