Opened 8 years ago
Closed 8 years ago
#8909 closed enhancement (fixed)
$(element).data() will scan all attributes more than needed.
| Reported by: | gnarf | Owned by: | gnarf |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.7 |
| Component: | data | Version: | 1.5.2 |
| Keywords: | 1.7-discuss | Cc: | |
| Blocked by: | Blocking: |
Description
If you make more than one call to $(element).data() you end up having to loop over the attributes of the element looking for "data-" attributes every time you access it. I'd like to propose adding a simple flag in our private _data() that can stop us from having to check more than once...
Change History (13)
comment:2 Changed 8 years ago by
| Component: | unfiled → data |
|---|---|
| Status: | new → open |
| Type: | bug → enhancement |
comment:3 Changed 8 years ago by
| Owner: | set to gnarf |
|---|---|
| Status: | open → assigned |
comment:10 Changed 8 years ago by
+1, Anything we can do to improve the perf of $(element).data("yesplease!")
comment:11 Changed 8 years ago by
| Milestone: | 1.next → 1.7 |
|---|---|
| Priority: | undecided → blocker |
comment:12 Changed 8 years ago by
Updated the pull request in comment #1 - http://jsperf.com/internal-data/3 has some perf data
comment:13 Changed 8 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Landing pull request 503. 1.7 data: set a flag in the private data cache to avoid having to scan attributes multiple times - Fixes #8909.
More Details:

https://github.com/jquery/jquery/pull/503