How To Load External Script From JavaScript Function - Save My Knowledge
Friday, October 17, 2014

How To Load External Script From JavaScript Function

Hi, I have a problem that I need to call javascript function dynamically, it mean that what I call is not hardcode. We usually load external javascript just using <script src="scriptLocation"></script>, but if you call it inside <script>, what would you do?


Actually, we can do that with "print" <script src="scriptLocation"></script> to the document. That simple.

You can do that with this code: document.write('\x3Cscript src="scriptLocation">\x3C/script>');

Note: You need to change "<" into "\x3C"