Lazify pat-select2: split registration from implementation#1615
Merged
Conversation
petschki
force-pushed
the
mockup-lazy-select2
branch
from
July 17, 2026 08:58
91dfce8 to
140838e
Compare
petschki
approved these changes
Jul 17, 2026
petschki
left a comment
Member
There was a problem hiding this comment.
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
force-pushed
the
mockup-lazy-select2
branch
from
July 17, 2026 10:13
140838e to
b465752
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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