Home  >  Article  >  Web Front-end  >  Is it stupid to use jQuery?

Is it stupid to use jQuery?

PHPz
PHPzOriginal
2023-09-04 12:45:12746browse

使用 jQuery 是愚蠢的吗?

We should make this public. There seems to be a general belief that jQuery users are ignorant, and often the designers. Where did this come from and is it true?


root

The JavaScript community at that time was not as vibrant and enthusiastic as it is now.

Let’s take a trip down memory lane; we’ll turn the clock back a few years – to the days before jQuery. The JavaScript world was a very different scene at the time. That community was far less vibrant and welcoming than it is today. Sure, there were libraries like Prototype; but they never caught the attention of the average user as quickly as jQuery. At the time, JavaScript was a widely hated language. Sometimes, it's easy to forget that sometimes developers refuse to take the necessary time to... you know... learn JavaScript! Instead, they simply copy and paste their way around, hoping to avoid leaving a nasty JavaScript stain on their pants.

DOM

What you mean is, "I hate the DOM API."

What these copy-paste addicts (I am one of them) don't realize is that when you say "I hate JavaScript" what you really mean (whether you realize it or not) is: "I hate the DOM API." No one is to blame for feeling this way. Especially in those days, when IE5 support comes into effect, things can get a little rough. The browser implementation of the DOM is the culprit; not the JavaScript language. This is because there isn't really any DOM specification. As a result, the browser does what it does best! We have innerHTML not because of a specification, but because the Internet Explorer team decided to put it in (at which point other browser vendors reverse engineered it and implemented it into their own browsers ). But the JavaScript language as a whole is solid.

In fact, many people, myself included, would say that JavaScript is truly beautiful as a language.

jQuery

Around that time, jQuery entered the scene and began to take the development community by storm. While other libraries like Prototype still retain a certain level of complexity and confusion for newbies, jQuery is very easy to master because everything is accessed through the jQuery object (ironically , it is often criticized).

Need to apply for a course? Simple; doing so is tailor-made for designers. jQuery allows you to query the DOM using known CSS selectors.

$('#container').addClass('ahh-yeah');

Fun Facts: Technically, although jQuery popularized the idea of ​​a CSS selector engine, it is heavily based on the work of Dean Edwards.

Then, at some point, the timeline deviated from this alternate reality...

This really couldn’t be simpler. By abstracting away complex code and browser quirks, developers can get on with what's important: creating websites and apps.

While jQuery’s community is growing by leaps and bounds, the library itself is also continuing to mature and take shape. The world is rosy.

Then, at some point, the timeline tilts into this alternate reality (well, not like Dr. Brown), and suddenly, if you mark yourself as a proud jQuery user, certain members of the JavaScript community will So feel the need to stereotype you as an ignorant "designer" (whether you are one or not) - certainly not a "JavaScript developer". How did this happen? JavaScript developers not using jQuery?


The Burden of Popularity

Everyone has their own opinion on the spotlight.

It’s natural that once you reach a certain level of popularity (for lack of a better term), you’re going to be subject to a lot of scrutiny. It seems like everyone has an opinion about the spotlight. For example, you have no doubt heard the endless criticisms of Catholicism. "They worshiped statues." Is this the only religious group with a questionable history? Of course not; but it's the biggest. The United States is one of the most powerful countries in the world. Naturally, everyone has their own opinion. "Americans are ignorant and fat." Ignore the good and focus on the bad.

jQuery is overwhelmingly the most popular JavaScript library. Again, everyone has an opinion. I've read countless criticisms - from what it doesn't do, to how the codebase is structured. Perhaps the biggest criticism of jQuery, however, comes from the simple fact that its users, on average, have less experience with plain JavaScript than with software like Mootools. While some see this as a drawback, I honestly think it's a plus - in a weird way.

The fact that jQuery has many inexperienced users is not its failing; This proves its appeal.


jQuery users don’t know JavaScript!

This is the argument you hear most. Proof again of jQuery, many people learn jQuery before they learn regular JavaScript. There have been countless debates as to whether this is a good thing. In fact, such discussions extend to all abstractions.

  • Before understanding the ins and outs of CSS, should designers use CSS preprocessors and frameworks such as Sass and Compass respectively?
  • Can Ruby developers use CoffeeScript without learning JavaScript first?
  • Should you use Modernizr before learning how to write a single functional test?
  • If you are just learning PHP, can you use CodeIgniter?

Personally, I feel like people who ask newbies to learn JavaScript before moving to jQuery are missing one thing: JavaScript and the DOM are scary! If you threw the ES5 spec at them, they would have a heart attack, unless they were actually interested in becoming a JavaScript developer. Many people just need to add some effects to their website. We can't always be on top of everything. Are they bad people for choosing their priorities? of course not.

JavaScript and the DOM are scary!

Compare this to simple math. When you first learned how to add 2 2, did you do it the official way? Of course I didn't; I used my fingers. I bet you did too. While this is a huge simplification of the problem, isn't it true for jQuery as well? It provides a simple and exciting entry point for new users of JavaScript. Do you really want them to learn about closures, objects, and global variables before learning how to do something interesting? Come on, come on, now.

A strict "learn the right way or you're a fool" perspective is naive and fails to take into account the various learning styles we all have.

I see jQuery as bait. Raise it over the user's head, get them excited, and then, when they feel ready, they will almost always move on to learn more plain JavaScript.

jQuery users write bad code

This is another large-scale generalization. Some of the largest and most influential companies in the world use jQuery. But yes, there are a lot of beginners who are still in the learning process. OK then; it happens. Bad code exists in every language. I write a lot of the content myself, I’m proud to say! The best we can do is offer advice and tips whenever possible rather than openly disdain them. We are all learning. Do we really need to attack certain people because they have different priorities and skills?

With popularity comes bad advice.

jQuery has managed to create this incredibly passionate community - from die-hard JavaScript developers to designers who are surprised at how easy it is to get things done. This enthusiasm subsequently led to countless jQuery tutorials written by community members—for better or worse. While still learning jQuery (something I'm still doing), I can guarantee I've given some terrible advice at one point or another. It's not that different from the PHP community. With popularity comes bad advice.


Ruby Community

This senseless teaching almost hurts the community. ​​p>

In the Ruby community, there is an interesting dynamic. Overall, the tutorials are written by veterans. In other words, if you're going to write a Ruby on Rails article or book, you should do so with rigorous scrutiny in mind. If you don’t have rich experience, you won’t dare to write. In some ways, this is an advantage. As a student, you can more easily feel confident that what you are learning is correct. On the other hand, PHP tutorials are everywhere. Writers sometimes focus on the insignificant and ignore the important. You'll often find Best Practices for PHP tutorials that describe whether it's faster to use single or double quotes. Of course, this meaningless teaching almost hurts the community. ​​p>

what do you like?

I must say, this is an interesting thing. Which one do you like? A smaller, passionate base, or a very popular base that encompasses all skill levels? Of course there are pros and cons to each.

There's no denying that many of us feel the need to be trailblazers. Remember when your parents started signing up for Facebook? Critics generally claim that the end of Facebook is near. Once you sacrifice exclusivity for broad appeal, people will instinctively start looking for the next thing. But that didn't happen. The same is true for jQuery. Of course, some users have moved to more comprehensive frameworks such as Dojo. But this is to be expected and should be a badge of honor for jQuery. For many people, the learning cycle looks like this:

  • Learn jQuery; get excited.
  • Realize that you have no idea what this refers to in different contexts. Learn JavaScript and gradually improve your old jQuery code.
  • (Optional) Advance your skills to the point where you need a more comprehensive framework for building large applications. Start looking at other tools like Dojo.

Is it that bad?


Actual deadline

Guys, we are not coding in binary.

There will always be people who advise you not to use libraries - period. However, given the current state of JavaScript and the DOM, I honestly think this is terrible advice - especially for newbies. They shouldn't be expected to struggle with frustrating browser inconsistencies early in the learning process. And, many times, abstraction is a very good thing! Guys, it's not like we're coding in binary here. When you use jQuery or any other popular library, you benefit from countless tests, bug fixes, and the best talent in the industry.

Now, of course, you don't need to use other people's frameworks. If you have the means, create your own library; that works too! The target is:

  • Standardize browser quirks
  • Write less code
  • Benefit from the thoughts of as many people as possible
  • Meet real deadlines and get work done

jQuery is not a "designer's library", but it is attractive to designers. It's not class-based like other libraries, but that makes getting started easier for newbies. So what we ended up with was a library that helped reignite the JavaScript community. It's simple enough to appeal to newbies and powerful enough to be used by the world's largest companies. Why is it being criticized again?

The above is the detailed content of Is it stupid to use jQuery?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn