Sometimes you need to get the script tag from HTML string ( and if not you can certainly checkout other useful blogs 😂 `haha`). Let’s proceed without interrupting you with my nuisance 😂.
You might ask, why get scripts at all? Well, here’s two reasons:
1. When you don’t know what to load until runtime.
2. When you want to load scripts in the runtime / dynamic.
I have recently faced the same situation which require to do both when finding scripts tags and loading them from external resources. The responses from saved database values determined which resources were required, so I couldn’t know what resources to get until runtime.
Let’s begin our solution:-
Method 1: Prototyping
Github Contribution are welcomed. If you have any suggestions to implement or found any issue feel free to raise issue in below repo or drop email at codeeshop2211@gmail.com
Furthermore to load scripts from external sources you can use below NPM package after fetching script tags using above methods
Thank You