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.
Global variable in browser JS means window.variable
, so I think it would be much faster then
$.data(document.body, 'some-reference-here', MyJsonObj);
just because this is only one touch of the object's property instead of function call, getting property of document and much staff inside of the data call. But another problem is polluting global scope. Maybe it's better to store this data somewhere inside the local scope of your script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With