jsakamoto / Toolbelt.Blazor.HeadElement

Head element support (change the document title, "meta" elements such as OGP, and "link" elements) for Blazor apps.
https://demo-blazor-headelement.azurewebsites.net/
Mozilla Public License 2.0
158 stars 11 forks source link

Could not find 'Toolbelt.Head.Title.query' ('Toolbelt' was undefined) but on Blazor WASM and DisableClientScriptAutoInjection = true #25

Open thepra opened 2 years ago

thepra commented 2 years ago

Hi, I saw the other issue which was about the server side type of project. Here I have a Blazor WASM project and I need offline functionality to work(so no dynamic loading of js).

How am I supposed to accomplish such setup? As of now I tried with that option disabled and included

<script src="_content/Toolbelt.Blazor.HeadElement.Services/script.min.js"></script>

in the index.html but it doesn't seem to do the trick, what should I do to make it work properly?

jsakamoto commented 2 years ago

@thepra Thank you for reporting!

I'll consider the offline scenario that you said.

By the way, I can not work on this issue right now, so I would appreciate it if you waited for my work to be finished.

jsakamoto commented 2 years ago

@thepra Thank you for waiting.

Today, I published the new version of "Toolbelt.Blazor.HeadElement" NuGet package.

I improved offline support at this version, so this package version should fix your issue. Could you try it out?

thepra commented 2 years ago

yep, with that option disabling client injection and putting the explicit link to the script in the index.html everything seems to work fine now :)

Last piece could be to add such documentation of this feature so people can understand what to do to accomplish offline caching from the beginning

jsakamoto commented 2 years ago

@thepra Thank you for replying. I agree that I should improve the document. And I'd like to do that as soon as possible.

By the way, in my test case, Blazor WebAssembly apps with PWA manifest and service worker scripts that use this library worked fine on offline mode even though the DisableClientScriptAutoInjection option is not set to true. (I implemented some extra code explicitly to support those PWA offline scenarios.)

So in my expectation, developers who use this library on their Blazor WebAssembly apps and need PWA offline support may have to do nothing special. I hope this information is also helpful for you.