+ 1
How to remove script tag with javascript and load it on scroll
I want to remove specific script tag that's loading inside document that contain a string after that i want to load the script that we removed on scroll. For example, myscript.js is loading inside </head> <head> <script src="/folder/code/js/myscript.js"> </head> I want to remove the script if contains string myscript.js without specifying folder. When the scroll event occurred i want to load myscript.js I know it is hard but possible. Any help will be appreciated. Thanks.
1 Réponse
- 1
You don't have to!
Inside myscript.js, wrap all the contents with window.onload = function(){
//content of myscript.js goes here
}
That is all. But remember any function declaration should not be wrapped