Comma-separated JQuery Selectors Performance
Please advise which way using selectors in jQuery is faster: $('.class1, .class2').html(''); or $('.class1').html(''); $('.class2').html('');
Solution 1:
In terms performance they seems to be almost same(7-8%), but in terms of maintainability the first method will be better since there is no duplication of code
Solution 2:
Single $('.class1, .class2').html('');
better as
- no duplication of code
- jQuery constructor is called only once which makes it little fast.(+3-4%)
Post a Comment for "Comma-separated JQuery Selectors Performance"