scripts do not execute when added.
See original GitHub issueWhen a script is added to the page either through a script with a src
attribute or an inline script it will not download the script or execute the inline code. Is this expected behavior?
Thank you!
Edit:
This does execute script tags which have a src attribute
{
onNodeAdded: function (node) {
if (node.nodeName === 'SCRIPT' && node.src) {
var script = document.createElement('script');
script.src = node.src;
node.replaceWith(script)
}
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Dynamically added script will not execute - Stack Overflow
But If I try to add it to the page after it loads it adds the script to the page but doesn't execute...
Read more >How is it possible that a <script> tag was injected, but not ...
To execute the script, you have to create the script element via createElement and append it to the DOM explicitly. Share.
Read more >18843 - dynamically added SCRIPT not executable
When I have added a SCRIPT element it shows up in the DOM but the inserted javascript is not defined. Press the insert...
Read more >Adding arguments and options to your Bash scripts - Red Hat
Bash uses a tool called positional parameters to provide a means of entering data into a Bash program when it is invoked from...
Read more >Using functions within a shell script
This code is not executed until the function is called. Functions are read in, but basically ignored until they are actually called.
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
The code below will execute JS code as it’s added/updated.
@snewcomer - thanks for your suggestion with
replaceWith
too! That worked perfectly! 🎉