You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I always provide a base path pointing to the location where my JS files are located, but it makes loading files from an absolute URL more difficult (Must remember to use $script.get directly) and more limited ($script() adds a lot of nice things over $script.get that are lost when calling $script.get directly).
Wouldn't it make sense to check if a script path is a valid URL already before prepending the configured base path? I can't think of a scenario when someone would supply a base path, and then expect that it will be prepended when they supply an absolute URL to $script(). I think the expected functionality in at least the majority of cases would be that the base path is prepended only to relative URLs, while absolute URLs are passed through unaltered.
In its current state, supplying a base path makes loading JS from an absolute URL lose all the benefits that $script() adds on top of $script.get(), which seems like a bigger downside than the performance hit that making an extra string check in $script() would make. If performance is a worry, there could be a simple boolean setting in $script which tells it whether or not to check for absolute URLs, which could even default to off so that it works as it did before unless set.
What are your thoughts on this? Are there any other reasons that I'm overlooking for why that might not be preferred to the current functionality?
Thanks!
The text was updated successfully, but these errors were encountered:
I would prefer this functionality you're talking about as I've definitely ran into this issue myself. I'll see if there's something I could add in that won't bulk up the library
Thanks, that sounds absolutely perfect! I will be making extensive use of this in most of my CakePHP apps, so I'll let you know if I run into any issues.
I always provide a base path pointing to the location where my JS files are located, but it makes loading files from an absolute URL more difficult (Must remember to use $script.get directly) and more limited ($script() adds a lot of nice things over $script.get that are lost when calling $script.get directly).
Wouldn't it make sense to check if a script path is a valid URL already before prepending the configured base path? I can't think of a scenario when someone would supply a base path, and then expect that it will be prepended when they supply an absolute URL to $script(). I think the expected functionality in at least the majority of cases would be that the base path is prepended only to relative URLs, while absolute URLs are passed through unaltered.
In its current state, supplying a base path makes loading JS from an absolute URL lose all the benefits that $script() adds on top of $script.get(), which seems like a bigger downside than the performance hit that making an extra string check in $script() would make. If performance is a worry, there could be a simple boolean setting in $script which tells it whether or not to check for absolute URLs, which could even default to off so that it works as it did before unless set.
What are your thoughts on this? Are there any other reasons that I'm overlooking for why that might not be preferred to the current functionality?
Thanks!
The text was updated successfully, but these errors were encountered: