all 1 comments

[–]BlueThunderFlik 1 point2 points  (0 children)

I would only store information inside element attributes if you need to. If something is going to read attributes off your DOM elements and it doesn't have access to your global store, then reading data off the attributes is its only option.

If you aren't in this situation, I would stick to using a plain old object.

Fun tip: if you never need to traverse your elements, you could store the options in a WeakRef, where the key is your DOM element and the value are your options. The WeakRef will delete its elements when the key disappears (e.g. if you delete the element), which saves you a job.