BlazorDynamicScriptLoad icon indicating copy to clipboard operation
BlazorDynamicScriptLoad copied to clipboard

About Multi-pages with Pre-Render

Open Yusuf-Vero opened this issue 3 years ago • 5 comments

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.

Yusuf-Vero avatar Aug 18 '22 18:08 Yusuf-Vero

Thank you Yusuf! Do you mind posting the code that worked for you?

lonix1 avatar Nov 12 '22 04:11 lonix1

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?

lonix1 avatar Nov 12 '22 10:11 lonix1

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

conficient avatar Nov 12 '22 12:11 conficient

Straight from the horse's mouth... should be good. I'll look into it, thanks.

lonix1 avatar Nov 12 '22 12:11 lonix1

One needs to ensure the script only loads once. Here is the solution.

lonix1 avatar Nov 16 '22 01:11 lonix1