This can be used to load a javascript file dynamically.

Code Snippet

function IncludeExternalJs(src) 
	var exScript = document.createElement('script'); 
	exScript.type = 'text/javascript'; 
	exScript.src = src;
	var script = document.getElementsByTagName('script')[0]; 
	script.parentNode.insertBefore(exScript, script);

Sample Usage

<script type="text/javascript">


Just call IncludeExternalJs function on page load or put that script somewhere in the body tag.

author's photo

Author : Blue Cloud

Just a normal software developer who love to write code. Developing professional software since 1999. After working in the software industry for many years, I've started my own website to share knowledges and experiences.

blog comments powered by Disqus