Comparison of DOM operation functions of native js and jQuery

Source: Internet
Author: User

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.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.