Home > Article > Web Front-end > Summary of Jquery's flaws_jquery
Yes, jquery has successfully explored selector, chain usage, gsetter usage, many simplified naming, etc., making the front end easy and simple, making a huge contribution to web development.
However, it also has some unsatisfactory aspects.
1. About one of the code lumps.
I have always felt that jquery is a product of personal heroism. The number of people who have the patience to read his code is definitely less than 1%.
After sizzle became independent, ms has undergone some changes.
But the styles that are different and related to each other are still everywhere in sizzle and jquery.
Sometimes I think: If John stopped writing code, who would be willing to take over these messes.
2. About Code Tuo No. 2.
I wonder if any component developers have ever thought about "relying on jquery to develop a component that can run independently without relying on jquery"?
Is this a strange requirement? ----It seems not.
Is there such a need? ----Many students will say: "JQuery has deep roots and can be relied on, so why should it run independently?"
Also, the level of component developers is generally pretty good, and they will find ways to solve these problems. . If there is such a need, they will find the corresponding method library.
However, this also shows that jquery cannot meet the needs of these people.
Because jquery is just a mess of code. It is almost impossible to split it into a static method library.
3. About the "focus on dom" one.
I don’t know whether to say yes or not.
I feel that jQuery’s team is definitely capable of building a comprehensive framework, rather than just “focusing on DOM”.
When using jquery and jquery components, we may have to find a seed file ourselves for asynchronous loading, etc.
Because these seed requirements are actually not closely related to the dom, so jquery can completely ignore it-----it is very lazy.
Also, regarding torrent files, YUI3’s use as the core point is a good idea, but it’s a pity that it goes too far. After arriving at YUI3, I wanted to use only its selector for performance comparison, but I had to load a push file to do it.
4. Regarding "focus on dom" part two.
“jquery focuses on dom”,
Does the string trim need to be in jquery? ----It seems unnecessary. But jquery provides it conveniently. Similar ones include parseJSON, globalEval, etc.
What about the string template function (tmpl)? ----The template should obviously be based on strings, because string templates are often used to organize html characters, so jquery will forcefully put them in. And it is based on DOM. ----I really want to say: It’s really far-fetched.
In our projects, we may also use many string-related functions (trim|subByte|encode4Hhtml, etc.), object-related functions (get|dump|mix, etc.), and array-related functions (forEach |map), etc.
Jquery has no intention of helping us solve these problems, so do we have to ask someone else to solve them or solve them ourselves?
5. About sizzle.
A: Sometimes I feel that sizzle is a semi-finished product, and some functions that could have been easily provided are not provided.
For example:
selector2filter(selector) //Convert a selector into a filter function.
filter(els,selector,refEl) //Use ref as the reference element and filter els according to the selector condition. For example, it is used when delegating. Since sizzle is not provided, the reference element of '>li' in $('#id').delegate('>li','click',handle) is not the object corresponding to #id
B: sizzle If you want to solve the following two problems, you may have to break your muscles.