Skip to content

Mockup lazy modal#1617

Open
MrTango wants to merge 2 commits into
masterfrom
mockup-lazy-modal
Open

Mockup lazy modal#1617
MrTango wants to merge 2 commits into
masterfrom
mockup-lazy-modal

Conversation

@MrTango

@MrTango MrTango commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Merge after the pat-recurrence PR #1614!

Lazify pat-modal: thin registration module + lazy jquery-form

Split the ~1000-line pat-modal implementation out of the every-page
eager patterns chunk. modal.js becomes a thin registration module that
loads modal--implementation.js on first .pat-plone-modal match; the
implementation grafts onto the instance from the prototype, since
imperative callers still do new Modal().

jquery-form ($.fn.ajaxSubmit) moves from a top-level import to a lazy
await import("jquery-form") at its single call site in
handleFormAction, so it no longer loads on every page.

Imperative importers are repointed at modal--implementation:
controlpanels (registry / dexterity-types-listing / contentrule-elements)
and recurrence load it as part of their own lazy implementation chunks;
manageportlets is registered eagerly, so it loads the impl on demand
inside showEditPortlet. Side-effect registration imports (patterns.js,
tinymce links, structure actionmenu) keep pointing at the thin module.

Depends on the pat-recurrence lazification: recurrence is eagerly
registered, so its Modal import must live in recurrence--implementation
(a lazy chunk) for the modal body to actually leave the eager bundle.

addresses #1618

MrTango added 2 commits July 17, 2026 10:50
…ntation

pat-recurrence was the single largest pattern in the eager patterns chunk
(~52KB src, incl. three statically-imported XML templates and the Modal
dependency), loaded on every page though the widget only appears on Event
add/edit forms.

Split it into a thin registration module (trigger, parser, and an init()
that dynamically imports the implementation on first match) plus
recurrence--implementation.js holding the widget, the XML templates and the
Modal import. Follows the existing tinymce--implementation lazy-pattern
convention. Public options and markup contract are unchanged.

The implementation now loads only on pages with a .pat-recurrence element,
in its own chunk.
Split the ~1000-line pat-modal implementation out of the every-page
eager patterns chunk. modal.js becomes a thin registration module that
loads modal--implementation.js on first .pat-plone-modal match; the
implementation grafts onto the instance from the prototype, since
imperative callers still do `new Modal()`.

jquery-form ($.fn.ajaxSubmit) moves from a top-level import to a lazy
`await import("jquery-form")` at its single call site in
handleFormAction, so it no longer loads on every page.

Imperative importers are repointed at modal--implementation:
controlpanels (registry / dexterity-types-listing / contentrule-elements)
and recurrence load it as part of their own lazy implementation chunks;
manageportlets is registered eagerly, so it loads the impl on demand
inside showEditPortlet. Side-effect registration imports (patterns.js,
tinymce links, structure actionmenu) keep pointing at the thin module.

Depends on the pat-recurrence lazification: recurrence is eagerly
registered, so its Modal import must live in recurrence--implementation
(a lazy chunk) for the modal body to actually leave the eager bundle.
Merge after the pat-recurrence PR.
@petschki
petschki force-pushed the mockup-lazy-modal branch from 960d227 to ee6a5b5 Compare July 17, 2026 09:12

@petschki petschki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I've rebased this PR on top of the new #1614 commit, so once this is merged, the commit here disappears after rebasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants