-
Notifications
You must be signed in to change notification settings - Fork 939
Description
$('#id1,#id2')
I had written 2 simple examples about it.
http://jsfiddle.net/WSA6f/
http://jsfiddle.net/WSA6f/1/
The two are both the same html and javascript code,except the onload-jquery-library,the 1st one contains jq-1.8.2 and the 2nd uses jq-1.7.2.
USE IE(<=8,cause I add a meta 'X-UA-Compatible' to make IE8 likes IE7) to open the example url,check the cost time and u'll see the 1st cost about 40ms and the 2nd cost only 1ms.
Yes I can split the selector or write like this $('#id1') .add('#id2') then the time will be shorter than 1ms.But WHY the same code in 1.7.2 is faster?
Yes I can get the same result dom elements at last ,so it seems not a big bug ,I can not confirm it is a bug or not,but I think the code may need to be optimized.
I knew that IE7 or lower browser didn't support the querySelectorAll(in sizzle I found the code like 'if(document.querySelectorAll)'),but I think that is not the main reason why 1.8.2 is slower.
I ran into the sizzle1.8 complicated source code and get somthing like:
compile( selector, match )(//in line 5154 ,jquery-1.8.2 source
seed,
context,
xml,
results,
rsibling.test( selector )
);
The above code build a anonymous function and execute it but it cost too much time.
Anyone can give me some ideas about it? The result may be very important to me cause I decide to change my jquery-library from 1.7.2 to 1.8.2 in my company site.
Much Appreciate!