If I have a plugin that makes reference to the same JQuery objects constantly I figure I should cache the reference.
I was wondering if anyone knew off hand how much memory a jquery reference takes up?
Also I do understand that the price of the JQuery lookup far exeeds the price of the reference itself.
$('sameElement')
vs
this.sameElement = $('sameElement');
this.sameElement
It'll be the same as any other object reference, plus the memory of any of its own properties.
Its own properties are:
.length
Number (64 bit) showing the current elements in the collection
.prevObject
Reference to another jQuery object, which will hold reference to the previous set of elements (can be a memory leak in some cases)
.context
Context element from which the selection was made
.selector
Your selector string
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