Skip to content

Lazify pat-select2: split registration from implementation#1615

Merged
petschki merged 1 commit into
masterfrom
mockup-lazy-select2
Jul 17, 2026
Merged

Lazify pat-select2: split registration from implementation#1615
petschki merged 1 commit into
masterfrom
mockup-lazy-select2

Conversation

@MrTango

@MrTango MrTango commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

pat-select2 contributed ~13KB src to the eager patterns chunk on every page, plus a lazy select2_locale_* context map baked into the eager chunk, though select2 widgets only appear on forms. (The select2 library itself was already an async chunk; only the wrapper and the locale map were eager.)

Split it into a thin registration module and select2--implementation.js holding the wrapper, the select2 library import and the select2_locale_* context. The implementation is grafted onto the single pattern instance in init(). Public options and emitted markup are unchanged.

pat-relateditems borrows select2's methods (Select2.prototype.* applied to its own instance). To keep that working without pulling select2 back into the eager chunk, relateditems now imports select2--implementation lazily in its init() and calls the borrowed methods through it. This is the coordinated change flagged between the select2 and relateditems lazification tickets.

The select2 wrapper and locale map now load only on pages with a .pat-select2 or .pat-relateditems element.

addresses #1618

@MrTango
MrTango requested a review from petschki July 13, 2026 19:56
@petschki
petschki force-pushed the mockup-lazy-select2 branch from 91dfce8 to 140838e Compare July 17, 2026 08:58

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

Also the relateditems import fix 👍🏼

…tion

pat-select2 contributed ~13KB src to the eager patterns chunk on every page,
plus a lazy select2_locale_* context map baked into the eager chunk, though
select2 widgets only appear on forms. (The select2 library itself was already
an async chunk; only the wrapper and the locale map were eager.)

Split it into a thin registration module and select2--implementation.js
holding the wrapper, the select2 library import and the select2_locale_*
context. The implementation is grafted onto the single pattern instance in
init(). Public options and emitted markup are unchanged.

pat-relateditems borrows select2's methods (Select2.prototype.* applied to
its own instance). To keep that working without pulling select2 back into the
eager chunk, relateditems now imports select2--implementation lazily in its
init() and calls the borrowed methods through it. This is the coordinated
change flagged between the select2 and relateditems lazification tickets.

The select2 wrapper and locale map now load only on pages with a .pat-select2
or .pat-relateditems element.
@petschki
petschki force-pushed the mockup-lazy-select2 branch from 140838e to b465752 Compare July 17, 2026 10:13
@petschki
petschki merged commit 175c7bd into master Jul 17, 2026
3 checks passed
@petschki
petschki deleted the mockup-lazy-select2 branch July 17, 2026 10:17
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