I have added a note to this code and I hope it will help you.
<script type= "Text/javascript" charset= "Utf-8" >
(function () {
var doc = document,//defines individual names for the document object, and local variables are accessed faster than the global
WA = doc.createelement (' script '),//Create a <script> label
s = doc.getelementsbytagname (' script ') [0];//find the first <script> tag, it may be its own
Wa.type = ' text/javascript '//To add attributes to the <script> tag you just created, at this point: <script type= "Text/javascript" >
Wa.charset = ' utf-8 '; Set charset properties for labels,<script> don't need this, do you?
Wa.async = true; I don't know what it is, I've never seen it.
WA.SRC = (' https: ' = = Doc.location.protocol? ' https://': ' http://') + ' js.t.sinajs.cn/open/analytics/js/suda.js?version=20111118190824.js ';
Add src attribute to <script> tag, URL, if the current document's protocol is HTTPS https://otherwise http://then link to the path of JS js.t.sinajs.cn/open/analytics/js/ Suda.js?version=20111118190824.js
Finally, the label becomes
<script type= "Text/javascript" charset= "Utf-8" async= "true" src= "http (s)://js.t.sinajs.cn/open/analytics/js/ Suda.js?version=20111118190824.js "></SCR ipt>//Here I have manually added a space, otherwise it will be with the last script end tag conflict, this note
S.parentnode.insertbefore (WA, s);}) ()//finally add this tag to the page after the first <script> tag,
/*
The entire function is contained in an anonymous function to avoid conflicts with the name of the variable named outside.
The whole process is a dynamic loading of external JS file process, the advantage is that the browser will download the JS file in parallel, speed up the loading speed of the page.
In fact, at the end of the several doc to uninstall the reference is better,
doc = null;
WA = null;
s = null;
*/
</script>
This article links http://www.cxybl.com/html/wyzz/JavaScript_Ajax/20121211/34875.html
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service