Skip to content

Experiment: Lazy loading patterns#1275

Draft
thet wants to merge 5 commits intomasterfrom
lazy-patterns
Draft

Experiment: Lazy loading patterns#1275
thet wants to merge 5 commits intomasterfrom
lazy-patterns

Conversation

@thet
Copy link
Member

@thet thet commented Feb 16, 2026

This is an experiment for lazy loading patterns.

There are two approaches evaluated in this PR:

  1. Registry with lazy loading support: Instead of importing all the patterns in the bundle, a special configuration will be passed to the registry.init method. This contains the patterns name, the patterns trigger and a importer function.
    This works fine and all tests pass, but the drawback with this method is that the pattern name and trigger need to be known before importing the pattern. This leads to duplicate information.
    An intersection observer is importing the pattern module and initializing it, once the pattern becomes visible.

  2. Lazy initialization as an alternative. An intersection observer is initializing an already imported pattern module, once the pattern becomes visible.

The first approach would probably give us the biggest benefit. But we need to find a better solution for the problem of needing to know the trigger and name before importing the module.

thet added 5 commits February 10, 2026 18:25
…eparated list of tag names which would be replaced in the inject response. This way you can allow to inject script tags.
…ey are executed. Otherwise they're not run nor is the script src downloaded.
Optionally allow to lazy load patterns, which will only be imported and initialized when they are visible, via an intersection observer.
Needs special pattern registration.
Support for lazy initialization of Patterns. The import is done eagerly, but the initialization only when an intersection observer detects that a pattern is being shown.
@thet thet marked this pull request as draft February 16, 2026 01:04
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.

1 participant