sivaganeshk
12-03-2012, 09:17 AM
Can I use the following to code to load many js files asynchronously?
<script type="text/javascript">
(function(){
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = '//mysite.com/ga.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(ga);
})();
</script>
Is it right?
<script type="text/javascript">
(function(){
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = '//mysite.com/ga.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(ga);
})();
</script>
Is it right?