I have a web application that is very dependent on jquery / javascript and its sometimes a little slow. One of the things that are often done is changes to the grid (jqGrid), which means every time I use jQuery to select this object, that is:
function load_editor() { $('#listview').jqGrid(do_stuff); }
I believe that just storing a link to $ ('# listview') - since using it in half a dozen functions - would be faster. So, is there a flaw in the setup:
listview = $('#listview');
function load_editor() { listview.jqGrid(do_stuff); }
It would seem that ordinary objects are already in memory and will not be subjected to a fine search with every use. Is there a drawback to structuring in this way?
(I know in my examples, I throw away the global one. Its all beautifully encapsulated in an object in the actual project, I just use these examples to illustrate my point.)
source
share