Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
Our company has a Razor Pages project that utilizes third party JS libraries that manipulate the DOM. We want to migrate the project to Blazor SSR when it becomes available, but in my testing, this seems to be a struggle.
When using a <script> tag inside a component, it will only execute on an initial page load. Enhanced navigation does not load the script. In a talk given by the blazor team, they discussed a js event that fires upon successful enhanced nav. You can write an event listener that executes your code when a page is navigated to. However, with this approach, the event listeners must still be initialized by a full page load, so this does not solve problem when it comes to page specific JS.
Secondly, I tried the IJSRuntime, which works, but requires an interactive render mode. Many of our pages require JS libraries, and we don't want to use signalr circuits every time we need to execute a simple js function.
Finally, when applying data-enhance-nav="false", <script> tags load correctly on each page since each page has been fully loaded, but pages flicker on navigation (firefox only), and we would really like to utilize the enhanced navigation SPA feel.
I raised this issue since our team is wondering what the recommended approach would be when migrating to blazor 8 ssr.
Describe the solution you'd like
Ideally, code inside a script tag would be executed when the page is navigated to. This would allow for existing projects that utilize JS libraries to migrate without relying on IJSRuntime, or disabling enhanced navigation.
Additional context
No response