Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/trivedikavit/gutenberg-autosave-indexed-db/archive/refs/heads/main.zipOverride Gutenberg's default autosave behavior to store large post content in IndexedDB, with a fallback to localStorage if IndexedDB is unavailable or fails.
This plugin enhances performance and avoids issues with large posts that may exceed browser storage limits when using WordPress's built-in autosave mechanism.
Features
- Stores Gutenberg editor content in IndexedDB for better handling of large posts.
- Falls back to localStorage if IndexedDB is not supported or fails.
- Automatically restores autosaved content on editor load.
- Lightweight and efficient, leveraging modern browser storage APIs.
- Uses the idb library for IndexedDB interactions.
Requirements
- WordPress 5.0 or higher (Gutenberg editor active)
- Modern browser that supports IndexedDB and localStorage
- PHP 7.0 or higher
Installation
Option 1: Manual Installation
- Download or clone this repository.
- Upload the entire
gutenberg-autosave-indexed-dbfolder to the/wp-content/plugins/directory. - Activate the plugin through the Plugins menu in WordPress.
Option 2: Via ZIP Upload
- Download the plugin as a
.zipfile. - Go to Plugins > Add New > Upload Plugin in your WordPress admin dashboard.
- Choose the
.zipfile and click Install Now. - Activate the plugin.
How It Works
This plugin overrides the default autosave behavior by:
- Listening for changes in the Gutenberg editor.
- Serializing the current post content into a string.
- Saving it to IndexedDB using the post ID as the key.
- Falling back to
localStorageif IndexedDB fails. - On editor load, restoring the saved content if it differs from the current content.
Technical Overview
JavaScript (gutenberg-autosave-indexed-db.js)
- Waits for the
idblibrary to load. - Initializes IndexedDB with a store for autosaved content.
- Subscribes to editor changes and saves content automatically.
- Attempts to restore content on load if autosaved data exists.
PHP (gutenberg-autosave-indexed-db.php)
- Enqueues the necessary JavaScript files only on Gutenberg editor screens.
- Loads the
idblibrary via CDN. - Ensures cache busting using
filemtime.
Browser Support
| Feature | Supported Browsers |
|---|---|
| IndexedDB | Chrome 24+, Firefox 16+, Safari 10+, Edge 12+ |
| localStorage | All modern browsers |
Configuration
No configuration is required. Just activate the plugin, and it will automatically begin overriding the Gutenberg autosave behavior.
File Structure
gutenberg-autosave-indexed-db/
│
├── js/
│ └── gutenberg-autosave-indexed-db.js
├── gutenberg-autosave-indexed-db.php
└── README.md
Author
Kavit Trivedi
License
This plugin is licensed under the GPL 2.0 or later.
Troubleshooting
Autosave is not working
- Ensure the plugin is activated.
- Check the browser console for JavaScript errors.
- Confirm that the
idblibrary is loading correctly.
Content is not restored
- Make sure the post ID is available when the editor initializes.
- Check IndexedDB storage using browser DevTools under Application > IndexedDB.
Feedback & Support
For issues, feature requests, or contributions, please visit the GitHub repository.
🙌 Contributions
Contributions are welcome! Feel free to submit a pull request or open an issue.
Special Thanks
Kata Grzegorczyk (@katag9k): — for debugging and identifying the edge case where Gutenberg Autosaves hit the browser's localStorage limit, which inspired this plugin.