.data(key, value) stores arbitrary metadata on elements using jQuery’s internal cache—separate from HTML data-* attributes but initialized from them on first read.
Why teams used it
Attach widget ids, plugin options, or lazy-load flags without polluting attributes visible in DevTools—handy before dataset was ubiquitous.
Pitfalls
- Do not store secrets or PII in DOM data
- Removing elements without
.remove()can leak memory in old patterns - Prefer
element.datasetwhen migrating to vanilla
Self-check
- How read data-tuto-id via jQuery?
- Why avoid sensitive tokens in .data?