JQuery (or Zepto) has been the benchmark for front-end development for many years and has become a must-have front-end framework. The main reason for its success is that it makes JavaScript easy to use and easy to understand, allowing beginners to quickly write complex interactive pages without being familiar with native JavaScript. Of course, it has a lot of advantages, but I won’t go into details. I’m writing this article because I’ve been working with other front-end frameworks for the last year or so, and I’ve given jQuery some new thought.

How did we use jQuery before the MV*(MVVM) framework?

This is a big problem, a thousand Hamlets for a thousand readers, and the level of understanding of jQuery, or JavaScript, varies from developer to developer. If you’re a beginner front-end developer, you might like to manipulate the DOM directly, so $() is flying all over the place. .hide(),.show(),.css(),.attr(),.html() are used frequently,.fadein (),.fadeout (),.slidedown (),.slideup () are also used to play animations. But then again, jQuery is really good at this. At first I thought, wow, this is great, I can finally make interactive pages, and I can easily get any DOM I want.

Then came Ajax. JQuery’s Ajax solution works well enough that many people know how to use jQuery Ajax and don’t know what XHR is, let alone write native Ajax. With DOM, data, and a couple of open source jQuery plugins, front-end development seems to be all it takes to create a complex interactive page. Yes, most of the front-end development on the market, probably come from this, and this part of the market share is not small.

Later, interactions become frequent, and direct DOM manipulation can take a lot of time to write a bunch of repetitive business logic code, leading to front-end templates such as doT and artTemplate. The developer simply maintains the data and then hands it off to the template, using event delegates to listen for events. This model became mainstream and is still used by many projects today. The advantage is that you can use both the front and back ends, and you don’t have to manipulate the DOM directly, which saves a lot of business logic code, is easy to maintain, and the performance is not bad.

How do we use jQuery when using Angular?

The advent of Angular has really changed front-end development practices and perceptions. Now that I think about it, if you haven’t used jQuery before, it might be a lot easier for you to learn ng. Otherwise, you’re always thinking about jQuery, which is why backend developers like to use NG for administrative backend products like TalkingData. Of course, when I first learned NG, I could not get rid of the shackles of jQuery. Although there is $HTTP service, I still like to use jQuery ajax, and then $apply, the plug-in still likes jQuery, because I am used to it. Ng and jQuery are used together, and we’re no longer manipulating the DOM, it’s all HTML and data. But is jQuery required? Of course not. Ng plugins are now rich enough to meet most interaction requirements, and even if they are not, ng plugins are preferred over jQuery, so jQuery is no longer an integral part of a project.

How do we use jQuery when using Vue?

I haven’t used vue.js for a long time, but I love this front-end framework, which is simpler to use than Angular, renders more efficiently, is well documented, and has a low barrier to entry. When I first developed TalkingCoder, I didn’t use jQuery. I wrapped Ajax and Document.Ready in my native language, and I didn’t have any problems at first because I didn’t directly manipulate the DOM. When I had to use the jQuery plugin, I started thinking about using Zepto instead of jQuery. Then I adapted the plugin to be Zepto compatible, because Vue was a new project and it didn’t have many components yet, but I didn’t want to spend too much time building wheels, so I compromised. Later, using the Simditor rich text editor, I switched to jQuery instead of Zepto.

Recently, I just finished a project, which is a complex interaction. The deep use of reusable components, vue.js can help a lot. I added jQuery without thinking too much about it at first, because I thought it might be useful. But at this point in the article, I did a global search and found that jQuery was almost nowhere to be used, adding up to maybe a few hundred lines of code, and when I looked back, it seemed like it was, and some of it could have been adapted to Vue.

conclusion

As for React, I haven’t studied it much, so I don’t know anything about it. In terms of Angular and Vue usage, jQuery is still in use, but it is not very useful, or even completely replaceable, and Zepto can replace jQuery if necessary. The front end has evolved so rapidly in recent years that jQuery is no longer the mainstream and its model is being overthrown by new ideas. So back to the question, what are we using when we use jQuery? In fact, the answer is very simple, why we use jQuery, because it has become the standard of front-end development in the past, can not do without it, of course, but you have to make your own set of things like document.getelementByID! So finally will come back to the question: what kind of framework, what technology stack depends on your current team strength and project, no who good who bad, who only at present, and any produces a framework, is in order to solve a particular problem, not a said struck down a framework is not good, maybe it’s just not suitable for the current you!

Copyright belongs to Aresn

The article was published on June 16, 2016