Is referencing a selector faster in jquery than actually calling the selector? if so, how much does it make a difference?
- by anthonypliu
Hi,
I have this code:
$(preview-button).click(...)
$(preview-button).slide(...)
$(preview-button).whatever(...)
Is it a better practice to do this:
var preview-button = $(preview-button);
preview-button.click(...);
preview-button.click(...);
preview-button).slide(...);
preview-button.whatever(...);
It probably would be better practice to do this for the sake of keeping code clean and modular, BUT does it make a difference performance wise? Does one take longer to process than the other? Thanks guys.