`callback` option for loading scripts
See original GitHub issueCurrently, useHead
does not provide a vue-meta-like callback
function to do something when a script has been loaded.
It’d be a nice DX feature IMO ☺️
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Introduction: callbacks - The Modern JavaScript Tutorial
The script is executed “asynchronously”, as it starts loading now, but runs later, when the function has already finished. If there's any code ......
Read more >Asynchronous Script Loading Callback - Stack Overflow
Async function with callback: · 1. The line o.u = '//' + u; should read o. · 2. s. · 1 · I...
Read more >Async Script Loader with Callback - CSS-Tricks
The success callback for jQuery.getScript is called once the script has been downloaded, but it's not guaranteed to be called after the script...
Read more >Dynamically loading multiple assets with a callback
I wanted to load the CSS and JavaScript in parallel and fire a callback function when both of them had finished loading. Here's...
Read more >JavaScript Introduction:callbacks | W3Docs Tutorial
function loadScript(src) { //creates the <script> tag and adds it to the page, after which // the script with the given src starts...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is available in v1, documentation is here: https://unhead.harlanzw.com/guide/guides/dom-event-handling
If you insert the script client side only, then
onload
is guaranteed to run as it won’t set thesrc
until the event listener is attachedAh I think there’s a larger bug actually in that stackblitz setup, it’s not removing the script when you click it a second time 🤔
The issue you mention is also there though, can be replicated by adding the same script in App.vue. A straightforward solution is just to set some global ref wherever you’re loading the script but I might be able to tinker with it so the onload always fires