As we all know, jQuery (JQ) is js-based code encapsulation, and its performance is definitely inferior to that of native js, especially for DOM-based operations. What we want to study today is what is the performance difference between the DOM operation functions of native js and jQuery in mainstream browsers, and whether the gap is obvious.
Test Platform: E5400 + 2G DDR2 + Windows 7 SP1 32bit
Browsers involved in the test include:
- FireFox: 3.6.3
- IE6
- IE8
- Chrome: 10.0.648
- Safari: 5.0.1
- Opera: 1, 10.01
Test method: for a function that processes an object at a time, it executes 3000 times cyclically. For a batch function, it processes 3000 objects at a time.
The result is as follows:
Result Analysis: In most cases, native js is indeed faster than JQ, and the fastest is executing getElementsByName in IE6, Which is 4000 times faster than JQ. The minimum value is 1.3 times.
The exception here is html value reading and writing. JQ is faster and faster than native js.
Finally, I have to say that you are too slow in the IE series. Wait for IE9 to change everything.