BlazorDynamicScriptLoad
BlazorDynamicScriptLoad copied to clipboard
About Multi-pages with Pre-Render
Hello,
This code is an epic fix for the problem mentioned in stackoverflow which is mine too, however, The code only works at first render and not working with multi-pages within pre-render mode.
Looking forward to hear from you! Regards.
Edit: Had to remove the check for the script in case it's loaded or not. works properly now.
Thank you Yusuf! Do you mind posting the code that worked for you?
Ok I see what you mean, I've removed this:
https://github.com/conficient/BlazorDynamicScriptLoad/blob/a48053e94929f8867f1370b846491a80c2b8834e/BlazorDynamicScriptLoad/wwwroot/js/scriptLoader.js#L19-L20
...And now it works when the script is loaded by multiple pages, or there are multiple components which use the same script.
But! that is not a solution, because the script will be added multiple times to the page.
@conficient Do you know how to resolve this issue?
Not looked into that. You may also want to look at @SteveSandersonMS JSModule code:
https://youtube.com/clip/UgkxNVp2yunt8GAZ2ZmdDduJ_DNWRS7jOJTj
The code is here: https://github.com/SteveSandersonMS/AudioBrowser/blob/main/MediaFilesAPI/Util/JSModule.cs
Straight from the horse's mouth... should be good. I'll look into it, thanks.
One needs to ensure the script only loads once. Here is the solution.