This project is not covered by Drupal’s security advisory policy.

Editing a node with dozens of paragraphs is slow. Paragraphs Lazy Widget hides those paragraph forms behind a button, so the page loads fast and only builds them when the editor actually clicks it.

The Paragraphs module lets editors build a page out of reusable components. Every one of those components is a real entity with its own edit form, and the standard Paragraphs widget builds all of those forms every time the host node form is opened — even for paragraphs that are collapsed, and even when the editor came to the page only to fix a typo in the title.

On a page with 40 or 50 paragraphs that means 40 or 50 nested forms, each with its own text editors, file widgets and validation. Editors see multi-second page loads, slow AJAX buttons and slow saves.

Paragraphs Lazy Widget provides a drop-in replacement widget. When a field holds a lot of items, it shows a one-line summary and an Edit button instead of the item forms. Nothing is built, rendered or validated until the button is pressed. Editors who need to change the paragraphs press the button and get the familiar widget back; editors who don't never pay for it.

Features

  • Deferred item forms. Above a configurable number of items, the paragraph subforms are not built at all. The editor sees the field label, a line such as "42 items are not loaded for faster editing", and a button.
  • Load on demand. Pressing the button loads the complete widget over AJAX, in place, without reloading the page. From that point on it is the ordinary Paragraphs widget, including on validation errors and further AJAX rebuilds.
  • Safe to save while collapsed. Submitting the host form with the field still deferred leaves the stored paragraphs exactly as they were. Editors can save a node without ever expanding the field.
  • No revision cascade for untouched fields. Normally, saving a new revision of the host node loads every referenced paragraph and saves a new revision of each one. A deferred field provably was not touched, so the new host revision simply keeps pointing at the paragraph revisions already in the database — no paragraph loads, no paragraph saves, no revision bloat. This is often a bigger win than the form build itself.
  • Configurable threshold. Small fields keep working exactly as before; only fields that are actually large get deferred. Set the threshold to 0 to switch the behaviour off for a given form display.
  • Nothing else changes. The widget extends the stable Paragraphs widget, so every setting you already use (title, plural title, edit mode, closed mode threshold, autocollapse, add mode, form display mode …) is still there and still works.

When would I use this?

Use it when a content type has a paragraphs field that routinely holds many items — long landing pages, course or product outlines, FAQ lists, imported content, anything where the count grows over time — and editors complain that the edit form is slow to open or slow to save. It is aimed at the "many items" problem specifically. If your paragraph forms are slow because a single paragraph is very heavy, this module will not help much.

Post-Installation

There is no global settings page, no new content type and no new permission. Enabling the module only makes a new widget available; nothing changes until you select it.

  1. Install and enable the module as usual.
  2. Go to Structure → Content types → [your content type] → Manage form display (or the equivalent form display of whichever entity type holds the field).
  3. Find your paragraphs field and change its widget from Paragraphs to Paragraphs (lazy-loaded).
  4. Click the gear icon to open the widget settings. Alongside the usual Paragraphs settings you get two extra ones:
    • Lazy load threshold — the number of items from which the forms are deferred. Default: 10. Set to 0 to always render immediately.
    • Lazy load button label — the label of the button. Leave empty to use "Edit [plural title]", e.g. "Edit paragraphs".
  5. Press Update, then Save, and open a node that has enough items to see the effect.

Things worth knowing

  • Pick the threshold for your content. The default of 10 is a starting point. If most of your nodes have 3–5 items, the widget will almost never defer and you will see no benefit; if they have hundreds, a lower threshold is better.
  • Validation while deferred. The individual item forms do not exist, so a validation error coming from a paragraph cannot be shown next to the offending field. Such errors are shown on the widget container instead, which tells the editor to load the items and look there.
  • Stable widget only. The widget extends the stable (classic) Paragraphs widget. It is not a variant of the experimental widget, so features that require the experimental widget (drag & drop mode, Add in between) are not available on fields using it.

Additional Requirements

Supporting organizations: 

Project information

Releases