The 2019, jQuery obsolete?

Many people say the initiative, "with Vanilla JS it, you do not need jQuery." Of course, we do not need too many things, no matter how good it is. I do not need jQuery, although it is quite good!

There is a page devoted to "why you may not need jQuery." It is trying to sell an idea is "jQuery is easy to bring people to the ditch." However, one of the best reasons to use jQuery is this: a single line of jQuery code can replace 10 lines of Vanilla JS code.

I think a lot of JS API, especially DOM API is very bad, because they are contrary to the people's aesthetic. el.insertAdjacentElement ( 'afterend', other) This line of code may not take effect, but $ (el) .after (other) but always enjoyable. Although I do not like the $ () function appearance, but it gives us a much better experience than DOM.

How to quickly get a sibling element of it? NextSibling or nextElementSibling with it? What is the difference between them? Which tour is another method which support it? When the people in order to thoroughly understand these doubts but busy access to MDN, I am convinced that in jQuery, we only need to use the next () or prev () can be.

Many common operations in JS API standard is very poor, where we can make a list, in speed "you may not need jQuery" pages, so it just did a beautiful thing!

For a variety of common tasks, you still need to look at the help function. "You may not need jQuery" page lists many such examples. You should choose a standard solution is to use jQuery, rather than each time need to copy and paste the answer from Stack Overflow's.

While browser compatibility is no longer a problem, but Vanil JS is still a problem, especially when you do not belong to that 85% of the mass of the column:

Here you can refer to the article: Why not make Hello CSS CSS variables.

You should use jQuery it? of course not. Add any dependencies are based on the complexity and expense of increased file size, but fortunately jQuery file is not large: compress it after the default build for the 30K, does not contain a custom ajax able to build up to 23K, but with querySelector alternative SizzleJS build files only 17K. In order to use jQuery to achieve a certain function, whether it is the original 30K, or 17K is optimized within an acceptable range.

You can look at the Bootstrap removing jQuery project, as an example, look at using vanilla JS need take much effort: they must write their own helpers; and had to give up due to too difficult to add support for IE browser; API It is not designed to be compatible, and has spent a year and a half will be replaced by jQuery Vanilla JS. What were the results? I can only say that this project does not look good effect.

I understand why they do it, yes, people want to use the Bootstrap in Vue.js while using jQuery Vue.js and have a little look stupid like that and other reasons, to allow them to consume energy from the jQuery Bootstrap removed.

People have many reasons to convince myself not to use jQuery: for example, you want to code reuse, or write only a small function. However, we should try to avoid jQuery do? the answer is negative. Why do not such a good thing too! jQuery full screen fly (jQuery all the things) probably not a good idea, but not completely abandon the jQuery Okay.

Some readers may be wondering "Vue.js, how to React, or other popular frameworks do?" This article aims to compare Vanilla JavaScript and jQuery, and I do not intend to detail the principle of front-end development.

As already expressed, I think we have no reason to stick to a simple JavaScript, mainly because I want to build a web page, using the simplest appropriate code quickly, and can be accessed to most people as possible. In my experience, the server generates templates, plus JavaScript ornament "progressive enhancement" style, often the best way to achieve the above purpose. It is usually easier to develop faster, bug less, but your laptop's fan will not wake the neighbors.

This means that the front frame is not okay? Is not, there is no absolute good or bad, but usually need to make some trade-offs. (Obviously, jQuery as well.)

Overall, I think the Web is a system for browsing the document, not the operating system. For most Web applications, a documented plan will work better. (Perhaps in the future, this is a topic worthy of further exploring new)

Footnote

I know you can use jQuery (sel) or window.jq = jQuery, but I'm not in a vacuum programming, I prefer the standard codes, whether good or bad, do all things in jQuery standard operating is $.

 

 

Guess you like

Origin blog.csdn.net/dj3235/article/details/91040061