-
Notifications
You must be signed in to change notification settings - Fork 84
Option to preload scripts but not render component. #515
Description
Is your feature request related to a problem? Please describe.
I have some components that can't be fully per-rendered for various reasons. Maybe they show pop-up notifications or the amount of data that they fetch is too high for preloading. I would like an option to preload the route but not render the actual component.
This can be particularly helpful when rendering a long list of the same type of things, but the user is likely to click only one. You can load the /orders/[id] route but avoid fetching the data for any (or all) of the actual orders.
Describe the solution you'd like
An option to preload the route but not mount it. I can see a few ways to provide this.
Maybe the component itself could declare that it isn't suitable for pre-rendering.
<!-- routify:options preload-instantiate=false -->
Or maybe the preload helper could take a parameter such as preload("/user/[name]", {instantiate: false}).
Describe alternatives you've considered
- Just skipping preloading. This works but makes navigation slower.
- Just render the first element in the list. Works but can be annoying to write and is only a mitigation anyways.
- Just render a fake node like
preload("/orders/0"). This is easier to write than 2 but is wasteful as the loaded data is useless and may cause confusing errors due to background requests for invalid IDs.