Open idanmashaal opened 1 year ago
Hi @idanmashaal,
You're correct, at the moment this isn't supported - at least, without editing the head.pode file any way, but yes this will be lost on an upgrade.
I can look at adding in support for toggling between where the custom JS files are loaded :)
Thanks @Badgerati - that would be a great feature enhancement with two new flags to the Import-PodeWebJavaScript. -Head ==> will import the script in the
html tag -Async ==> will add the "async" directive And we will be able to use any combination of it.Thoughts?
I hadn't even thought about async! For custom scripts that shouldn't be much of an issue, so an Async switch would work. The other will likely be a Set parameter allowing either Head or Body to be passed - say "-Location", with Body as default.
That sounds perfect! And if the parameters are not set, the behavior will be as it is now ?
On Tue, 13 Jun 2023 at 1:10 Matthew Kelly @.***> wrote:
I hadn't even thought about async! For custom scripts that shouldn't be much of an issue, so an Async switch would work. The other will likely be a Set parameter allowing either Head or Body to be passed - say "-Location", with Body as default.
— Reply to this email directly, view it on GitHub https://github.com/Badgerati/Pode.Web/issues/497#issuecomment-1588176919, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC4BOZLNBCTLTMTALGZ7ZDXK6HV3ANCNFSM6AAAAAAZCLVF7M . You are receiving this because you were mentioned.Message ID: @.***>
Yes, the default location would be "body", so would still work as it does currently if none of the new parameters are supplied.
Question
Hi, Currently when using Import-PodeWebJavaScript with the location of a file, lets say '/assets/js/custom_script.js' the script will be called at the bottom of the rendered html.
Some scripts require to be run on the head, either by importing the files or by embedding the script tag snippet. An example for this would be analytics, but of course not limited to this.
How would I achieve calling a custom script from the head tag and instead of the end of the rendered html? I searched open and closed issues, as well as reviewed the code and documentation but it's not clear to me if this is possible without modifying the head.pode file which I'm not sure is a good idea (what happens upon upgrades, etc).
Thanks, Idan.