Opened 9 years ago
Closed 9 years ago
#15059 closed bug (duplicate)
jQuery 2 $.data slower then jQuery 1
Reported by: | jbedard | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 2.0.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I recently tried replacing jQuery 1.10 with 2.0, however I ran into an issue where $.data was taking significantly longer in 2.0. I believe it is almost entirely from the use of Object.defineProperties in the 2.0 Data object, where 1.10 simply did an assignment.
Here's an attempt at comparing just the element expando assignment: http://jsperf.com/v1-v2-data
In my actual use case there is also DOM node cloning so the hit is not as drastic as that jsperf, but jQuery 2.0 was adding 200-300ms (about 30%) over jQuery 1.0 with certain datasets.
Is there a strong reason to be using Object.defineProperties/Property in 2.0?
Duplicate of #14839.
Unfortunately, a lot of ES5 features are slower than a reasonably equivalent implementation using only ES3 feaures. I'll be interested to see if this continues when ES6 features become widespread as well. Maybe asm.js has it right.