Skip to content

Lazify pat-upload: split registration from implementation#1616

Open
MrTango wants to merge 1 commit into
masterfrom
mockup-lazy-upload
Open

Lazify pat-upload: split registration from implementation#1616
MrTango wants to merge 1 commit into
masterfrom
mockup-lazy-upload

Conversation

@MrTango

@MrTango MrTango commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

pat-upload contributed ~17KB src to the eager patterns chunk on every page, though the upload UI only appears in folder contents and upload dialogs.

Split it into a thin registration module and upload--implementation.js holding the jquery/underscore/i18n wiring and the lazily-loaded Dropzone integration. The implementation is grafted onto the single pattern instance in init(), so consumers that instantiate Upload directly (pat-structure, pat-relateditems, the contentbrowser app) keep working. Public options and emitted markup are unchanged.

The implementation now loads only where a .pat-upload element exists.

addresses #1618

@MrTango
MrTango requested a review from petschki July 13, 2026 19:56
pat-upload contributed ~17KB src to the eager patterns chunk on every page,
though the upload UI only appears in folder contents and upload dialogs.

Split it into a thin registration module and upload--implementation.js
holding the jquery/underscore/i18n wiring and the lazily-loaded Dropzone
integration. The thin module keeps registering the .pat-upload trigger and
grafts the implementation prototype on first match. Public options and
emitted markup are unchanged.

pat-structure, pat-relateditems and the contentbrowser app construct upload
imperatively (new Upload(...)) and use the instance right away. The
implementation therefore stays a constructable Base.extend pattern and those
callers import it directly, so new Upload() yields a fully formed instance
synchronously. Registry.register is first-wins, so the eagerly imported thin
module remains the registered .pat-upload pattern; the implementation is
only reached via lazy chunks (the structure app view, the contentbrowser
component and the relateditems dynamic import).

Add a regression test asserting the implementation is constructable and
exposes its methods synchronously.

The implementation now loads only where a .pat-upload element exists.
@petschki
petschki force-pushed the mockup-lazy-upload branch from bfd684d to dc5068b Compare July 17, 2026 09:06

@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!

@petschki

Copy link
Copy Markdown
Member

/run-coredev-6.3-robottests

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