Summary of Jquery's shortcomings

Source: Internet
Author: User

Yes, jquery has successfully mined selector, chained usage, gsetter usage, many simplified names, and so on, making the front-end easy and simple and making great contributions to Web development.
However, it also has some unsatisfactory points.

1. About code.

I always think that jquery is a product of personal heroism. I have the patience to read his code. It is definitely less than 1%.
After sizzle is independent, ms has changed.
Sizzle and jquery are everywhere.
Sometimes I think: if John does not write the code, who would want to take over the code.

2. About code Tuo 2.

I wonder if any component developer has thought about "relying on jquery to develop a component that can run independently without relying on jquery "?
Is this a strange requirement? ---- It seems no.
Is there such a demand? ---- Many colleagues said: "jquery is already rooted in the tree, so it is cool and reliable. Why should it be run independently ."
Also, the level of component developers is generally good, and they will try to solve these problems. If this is necessary, they will find the corresponding keystore library.
However, this also shows that jquery cannot meet the needs of these people.
Because jquery is a code bulb. It is almost impossible to split a static keystore library.

3. About "Focus on dom.

I don't know whether to say yes or not.
I think the jquery team is absolutely capable of building a comprehensive framework, not just focusing on dom.
When using jquery and jquery components, we may have to find a seed file for asynchronous loading.
Because these seed requirements are actually not closely related to dom, jquery can be totally ignored-it is very lazy.
In addition, YUI3 regards use as the core of the seed file as a good idea. Unfortunately, it is a little too much. After arriving at YUI3, I wanted to use his selector for performance comparison, so I had to load a push file.

4. About "Focus on dom" II.
"Jquery focuses on dom ",
Does the trim of the string Need To Be In jquery? ---- It seems unnecessary. However, jquery is a good choice. Similar to parseJSON and globalEval.
What about the string template function (tmpl? ---- The template should be based on strings obviously, because string templates are often used to organize html characters, jquery will put it in far-fetched. It is dom-based. ---- I really want to say: It's really far-fetched.
Many string-related functions (trim | subByte | encode4Hhtml, etc.) and object-related functions (get | dump | mix, etc.) may be used in the project), functions related to arrays (forEach | map), and so on.
Jquery does not help us solve these problems. Do we have to solve them again?

5. About sizzle.
A: Sometimes I think sizzle is A semi-finished product. Some functions that can be easily provided are not provided.
For example:
Selector2filter (selector) // converts a selector into a filter function.
Filter (els, selector, refEl) // use ref as the reference element and filter els Based on selector conditions. For example, it is used in delegate. Because sizzle is not provided, $ ('# id '). the reference element of '> li' in delegate ('> li', 'click', handle) is not the object corresponding to # id
B: If sizzle wants to solve the following two problems, it may hurt.Copy codeThe Code is as follows:

<Ul> <li> details 1.1 </li> <li> details 1.2 </li> </ul>
<Ul> <li> details 2.1 </li> <li> details 2.2 </li> </ul>
<Script>
Alert ($ ('# head1 ~ Ul> li '). length); // It should be 4 instead of 0. Because sizzle is lazy in the Candidate Set and does not seriously deal with the problem of the Candidate Set
</Script>

Copy codeThe Code is as follows: <ul>
<Li>
<Div>
<Div>
<Span> required </span>
</Div>
</Div>
</Li>
<Li>
<H1>
<Div>
<Span> not required </span>
</Div>
</H1>
</Li>
</Ul>
<Script>
Alert ($ ('Li> div span '). length); // It should be 1 rather than 0. Because sizzle is lazy in filtering, it ignores backtracking.
</Script>

C: A little bit of thinking. There are a lot of Sizzle code. There are as many as 13 K after YUI, and there are more than 11 K without the additional abbreviations.

6 ....
I am tired. I will talk about it later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.