I need to store relatively larget bit of JSON for global access in my web app.
Should I use jquery's $.data(document.body, 'some-reference-here', MyJsonObj); or a global?
I know binding $.data() to document.body is faster than to a jquery object, but how does this compare to global variable?
I'm interested the most efficient memory usage.
$.data()will result in a negligible amount of extra memory compared to a global variable, since ultimately all that$.data()does is store a reference to a variable (which could even be your global) in a DOM element..data()but changes to that data did not then appear in the HTML data attribute.