Yes, jquery successfully digs selector, chained usage, gsetter usage, many lite names, and so on, making the front end easy and makes a huge contribution to web development.
However, it also has some unsatisfactory places.
1. About one of the code Tuo.
Always think jquery is a product of individual heroism, have the patience to read his code, absolutely less than 1%.
After Sizzle Independent, MS has changed a little.
But the style of a lump-and-sizzle, or in the same place, is everywhere.
Sometimes think: If John doesn't write code, who would want to take over the lump.
2. About code Tuo bis.
Does the component developer think "rely on jquery to develop a component that can run independently without jquery?"
Is this an odd demand? ----don't seem to be.
Is there such a demand? ----Many students will say: "JQuery has Stagen good shade can rely on, why also to run independently." ”
Also, the level of component developers is generally good and they will find a way to solve these problems. If there is such a need, they will find the corresponding method library.
However, this also shows that jquery does not meet the needs of these people.
Because jquery is a code lump. It is almost impossible to disassemble the static method library.
3. About one of "focus on Dom".
I don't know whether to say or not.
Think of the jquery team as being absolutely capable of doing a comprehensive framework, not just stopping at the "focus on Dom" point.
Using the jquery and jquery components, we might also have to find a seed file for asynchronous loading.
Because these seed requirements, in fact, are not closely related to the DOM, so jquery can completely disregard-----is very lazy ah.
Another, about the seed file, YUI3 put use when the core point is a good idea, unfortunately played a bit too much. After the YUI3, I want to use his selector to make a performance comparison, unexpectedly to load a push file to do.
4. About "focus on Dom" bis.
"jquery is focused on DOM,"
Does the trim of the string need to be in jquery? ----don't seem to need it. However, jquery is conveniently provided. Similarly, there are Parsejson, globaleval and so on.
What about the String template feature (Tmpl)? ----templates should obviously be based on strings, because string templates are often used to organize HTML characters, so jquery will put it in a far-fetched place. and is based on DOM. ----I really want to say: it's really far-fetched.
In the project, we may also use a lot of string-related functions (trim|subbyte|encode4hhtml, etc.), object-related functions (get|dump|mix, etc.), array-related functions (FOREACH|MAP), and so on.
These questions, jquery does not help us to solve the meaning, then we all have to talant or solve themselves?
5. About Sizzle.
A: Sometimes feel that sizzle is a semi-finished product, some can be conveniently provided by the function, but did not provide.
For example:
Selector2filter (selector)//Convert a selector into a filter function.
Filter (Els,selector,refel)//to ref as the reference element, filtering Els according to selector condition. For example, it is used when delegate. Because sizzle did not provide, which resulted in $ (' #id '). The reference element of ' >li ' in Delegate (' >li ', ' click ', handle) is not a #id corresponding object
B:sizzle If you want to solve these two problems, you may have to bones.
Copy Code code as follows:
<H1 id= "Head1" > Theme <ul><li> Detail 1.1</li><li> Detail 1.2</li></ul>
<ul><li> Detail 2.1</li><li> Detail 2.2</li></ul>
<script>
Alert ($ (' #head1 ~ul>li '). length);//should be 4 instead of 0. Because sizzle is lazy when it comes to candidate sets, there's no serious problem with candidate sets.
</script>
Copy Code code as follows:
<ul>
<li>
<div>
<div>
</span> required by <span>
</div>
</div>
</li>
<li>
<div>
<span> do not need </span>
</div>
</li>
</ul>
<script>
Alert ($ (' li>div span '). length); It should be 1, not 0. Because the sizzle in the filter to steal lazy, the backtracking of the situation to ignore.
</script>
C: A little idea, sizzle code a little more. Yui after a lot of 13K, remove his amount plus a few abbreviations, there are more than 11K.
6...
Said tired, later to say.