Home >Web Front-end >JS Tutorial >Asynchronously dynamically load JS and run (sample code)_javascript skills

Asynchronously dynamically load JS and run (sample code)_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:09:191080browse

As shown below:

Copy the codeThe code is as follows:

(function(){
var ga=document.createElement('script');ga.type?=?'text/javascript';?ga.async?=?true;
ga.src?=?('https:' ?==?document.location.protocol???'https://ssl'?:?'http://www')? ?'.google-analytics.com/ga.js';
var? s?=?document.getElementsByTagName('script')[0];?
s.parentNode.insertBefore(ga,?s);

})();

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn