Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[StimulusBundle] About lazy loading & configurability#62217

Unanswered
Qronicle asked this question inQ&A
Discussion options

Hi, not sure if this is the correct place, but here goes:

We've been using Symfony's asset mapper component and stimulus controllers for basically all JS functionality in our latest project. Because of reasons I only noticed today that all the controllers and dependencies are loaded on every page (including wysiwygs, D3, ...).

I started with lazy loading the main offenders using the/* stimulusFetch: 'lazy' */ comment. But this got me thinking about the whole procedure.

If I understand it correctly, ideally you want all things that arereally needed on a page in the modulepreload list, which is at the moment a list of all things in the app.entrypoint. This entrypoint contains all imported files, excluding the lazy-loaded controllers.

So this means that even if I would go through the trouble of creating specific entry points for each of my pages, I cannot (easily) change the loading behavior of the controllers.

Are there any best practices or resources about this of how to tackle this for larger projects?


I was thinking about creating a Merge Request to make the lazy loading (fetchMode) configurable in config files rather than with the magic comment (although I would still support it as a fallback). Have a default fetchMode etc...

But now I'm not sure if this is enough, and maybe the controller fetchMode should be configurable (overrideable) for each entrypoint. And we could have page specific entrypoints maybe? It would also be cool if these page entrypoints could then be made automagically based on which template is rendered (we could try and gather the controllers that are used after processing the template or maybe even after rendering, maybe we have a twig function so the user can define the stuff that should be included, ...)

Maybe I'm overthinking this and I should just make every non-critical controller lazy-load. Maybe I'm missing something obvious to make this all more manageable.

Anyways, I would appreciate some thoughts or feedback on the matter :)

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@Qronicle

[8]ページ先頭

©2009-2025 Movatter.jp