---
title: How it works
url: https://lhero.org/portfolio/lh-persistent-forms/how-it-works/
date: 2026-11-14T15:28:18+11:00
modified: 2026-11-14T16:45:26+11:00
type: lh-portfolio-doc
---

- **Part of:** [LH Persistent Forms](https://lhero.org/portfolio/lh-persistent-forms/)

On the front end the plugin loads one small script module, which waits until the browser is idle. Values are kept only in the visitor’s own browser, in IndexedDB through the shared `idb-keyval` module. Nothing is sent to the server.

### Per-page fields

Fields matching the local selectors (by default `#comment`) are saved as the visitor types, keyed by the page URL without its fragment and by the field’s ID, so they need an ID. If the visitor comes back to the same page before submitting, the text is put back. Submitting the form clears it.

### Site-wide fields

Fields matching the global selectors (by default `input[type="email"]` and `input[autocomplete="name"]`) are saved when they change, keyed by the selector, and filled in on any page of the site where a matching field is empty. They’re kept after submitting. If a field matches both lists, it is treated as site-wide.

A saved value only fills an empty field. Passwords, hidden fields, files, checkboxes, radio buttons and buttons are never stored, and only fields inside a form are handled.

### Filters

- `lh_persistent_forms_return_local_selectors`: array of CSS selectors for per-page fields.
- `lh_persistent_forms_return_global_selectors`: array of CSS selectors for site-wide fields.
- `lh_persistent_forms_should_load`: whether to enqueue the module on this request (front end only by default).
- `lh_persistent_forms_init_plugin`: return false to switch the plugin off without deactivating it.

### The idb-keyval library

The module imports `idb-keyval`. When LH idb-keyval is active, every plugin shares its copy. Otherwise the plugin registers its own bundled idb-keyval 6.3.0, and Site Health and the Plugins screen say so. Requires WordPress 6.7 or later, for script module data.