Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hom much memory does a Jquery Element Reference Take Up?

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
like image 733
Dan Baker Avatar asked Dec 23 '13 16:12

Dan Baker


1 Answers

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

like image 193
cookie monster Avatar answered Nov 13 '22 11:11

cookie monster