Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.8k
-
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 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 :) |
BetaWas this translation helpful?Give feedback.