2
I’m creating a system where I need to record many DOM elements in variables.
Is there any difference of memory consumption in writing HTML elements x jQuery objects?
HTML elements:
var elemento = jQuery('#elemento')[0]; //mesmo que document.getElementById('elemento')
Object jQuery:
var elemento = jQuery('#elemento');
In my layman’s view, I think the first option would consume less memory by just recording the DOM element, and in the second is generated a new jQuery object that carries within it such an element.
Proceeding?
using native functions is always "light", but memory should only be a problem if the system is geared towards mobile phones
– Pedro Sanção