Probably this can’t be done, but in case I’m missing something:
Is it possible to temporarily modify the jQuery id selector(“#”) so as to operate on say…a DocumentFragment, or an element removed from the DOM instead of the default behavior?
The reason I’m asking is that I’m trying to optimize some legacy code that heavy utilizes id selectors in order to perform some heavy-lifting DOM manipulation. However, all those ids are under a single element. I read that if that element was removed from the dom, manipulated, and then inserted back performance would be much better. Which can’t be done because of all those “#” selectors…
(Sidenote: performance was noticeably improved by setting display:none before the manipulation, but still slow).
Selectors can only select from the DOM. What you want to do is store those fragments as JavaScript variables.
http://jsfiddle.net/mblase75/tjVUM/