Set the followingCodeAdd to the beginning of JavaScript
/* @ Cc_on _ d = Document; EVAL ('var document = _ D ')@*/
The document with such a line of code Ie can be accessed at least five times faster
The following is the test comparison code before and after joining
// Before
VaR date = new date;
For (VAR I = 0; I <100000; I ++) document;
Alert (new date-date); // 643
/* @ Cc_on _ d = Document; EVAL ('var document = _ D ')@*/
// After
Date = new date;
For (VAR I = 0; I <100000; I ++) document;
Alert (new date-date); // 145
The speed has improved a lot!
Explanation:
First, if the document in IE is directly called, the internal function of the window object is executed, which is inefficient. Based on this, the following processing can increase the speed:
VaR Doc = document;
Document; // slow
Doc; // This is faster than the above (document)
Although it can be directly used for writing like above, it is a little troublesome to replace all the documents used previously. So, let's look at the following:
VaR Doc = document;
VaR document = Doc;
That would be great if it could be implemented ......
People who know JavaScript should know that JavaScript variables are generated at the very beginning, so the document here becomes undefined.
It doesn't matter. continue to improve ~
VaR Doc = document;
Eval ('var document = doc ');
The eval function is to change the variable within the scope. In this way, the subsequent document can be used normally.
Finally, add the conditions that are only valid in IE, just like the following ~
/* @ Cc_on
VaR Doc = document;
Eval ('var document = doc ');
@*/
In the following way, global variables other than document can also be used to accelerate the process.
/* @ Cc_on
Eval (function (props ){
VaR code = [];
For (VAR I = 0 L = props. length; I <L; I ++ ){
VaR prop = props [I];
Window ['_' + Prop] = Window [prop];
Code. Push (prop + '= _' + Prop)
}
Return 'var '+ code. Join (',');
}) ('Document self top parent alert setinterval clearinterval
SetTimeout cleartimeout '. Split ('')));
@*/
Reprinted:Http://purpen.javaeye.com /? Page = 8 & show_full = true