Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Storing data in HTML elements

See this jsPerf test.

The most performant way to store data related to a certain element is to use a Map. Besides being the fastest, it also allows you to store arbitraty data. Using dataset and data-* attributes only allow for string values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment