Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Java Programming IT

JavaScript Devs: Is It Still Worth Learning jQuery? 218

Nerval's Lobster writes: If you're learning JavaScript and Web development, you might be wondering whether to learn jQuery. After nearly a decade of existence, jQuery has grown into a fundamental part of JavaScript coding in Web development. But now we're at a point where many of the missing pieces (and additional features) jQuery filled in are present in browsers. So do you need to learn jQuery anymore? Some developers don't think so. The official jQuery blog, meanwhile, is pushing a separate jQuery version for modern browsers, in an attempt to keep people involved. And there are still a few key reasons to keep learning jQuery: Legacy code. If you're going to go to work at a company that already has JavaScript browser code, there's a strong possibility it has jQuery throughout its code. There's also a matter of preference: People still like jQuery and its elegance, and they're going to continue using it, even though they might not have to.
This discussion has been archived. No new comments can be posted.

JavaScript Devs: Is It Still Worth Learning jQuery?

Comments Filter:
  • by lgw ( 121541 ) on Monday April 27, 2015 @04:08PM (#49563611) Journal

    I hear great things about that new-fangled VanillaJS [vanilla-js.com] framework. Very lightweight and fast, and already more popular than jQuery.

    • by halivar ( 535827 ) <`moc.liamg' `ta' `reglefb'> on Monday April 27, 2015 @04:45PM (#49563935)

      I will admit: I looked at the page and was very interested and got super excited until I looked at the code examples harder. Well played, internet... well played.

    • by Stewie241 ( 1035724 ) on Monday April 27, 2015 @05:05PM (#49564103)

      Not defending jQuery, but I think the VanillaJS page over simplifies things and it's examples are not quite equal, and seem to tout themselves as far better, when in fact, there is a lot of complexity that something like jQuery hides.

      Examples:
      1. AJAX - sure, you can memorize the special incantation of r.onreadystatechange and remember that you have to check if readyState is 4 (4? wtf?) and status isn't 200. Except in the little excerpt there there is no error handling, and you basically end up with an unresponsive page with anything except the happy path.
      2. Fadeout - sure, you can do the same thing in approximately the same number of characters, but the vanilla example is far more difficult to read and interpret.
      3. Selector speed - sure, it might be a lot faster to do getElementById or getElementByTagName, but again, you sacrifice a lot of readability and without good tools it is really cumbersome to write.

      If performance is an issue, perhaps a different, Javascript compiler is the solution. But to suggest that everybody should hand code everything in native JS instead of using the more convenient syntax that a library provides is ridiculous.

      • XMLHttpRequest.DONE === 4

        Nobody bothers to use the long form. But it's there.

        • by _xeno_ ( 155264 )

          You mean it's there now. Going back through previous version of the XMLHttpRequest spec, it wasn't added until June 2007 [w3.org].

          Who knows when it finally made it into enough browsers to be safe to use. By now no one uses it more out of momentum than anything else, but it wasn't a part of the spec originally, and people writing tutorials would use "4" because that would work even in browsers that hadn't been updated to use the latest spec.

      • by narcc ( 412956 )

        To your examples
        1. If you're really that slow, write a single, very short (If performance is an issue,

        Performance usually doesn't become an issue until you start using jQuery. Nothing kills your UI faster than that nightmare.

      • by _xeno_ ( 155264 ) on Monday April 27, 2015 @06:59PM (#49564887) Homepage Journal

        Basically this. jQuery is one of those things that's almost literally bloat: it adds nothing that your browser can't already do, it just wraps around it. You absolutely do not need to use it.

        However it saves on development time. It's effectively a bunch of boilerplate code that you don't have to deal with. It's one of those things that if you were to decide not to use it, you're likely to end up rewriting a chunk of it by the time you're done anyway, so you might as well go ahead and use it from the get-go and save yourself some time.

        (Which isn't to say you should always use it. I've written pages where the amount of dynamic code was small enough that using jQuery would make absolutely no sense. But the larger your project gets, the more sense it makes to use frameworks like jQuery.)

        • by lgw ( 121541 )

          In a trade-off between speed for the user, and development time, there's never one 100% true answer. Everything depends on what you're developing. But a bias towards the user is a good mindset to cultivate.

        • by Lobo42 ( 723131 )

          "jQuery is one of those things that's almost literally bloat: it adds nothing that your browser can't already do, it just wraps around it."

          Technically, isn't that true of any library or framework in any Turing-complete language?

          • by mwvdlee ( 775178 )

            It's technically true of anything except machine code. Ever assembler is an abstraction.
            And even then, a CPU is just a generalized abstraction of dedicated chips.

        • by dave420 ( 699308 )
          You are forgetting something rather crucial which jQuery provides - cross-browser compatibility with the same code. You talk of "your browser", when jQuery targets all modern browsers. Without mentioning that it seems you might not fully understand the benefits, which I'm sure was just an oversight on your part.
      • by edxwelch ( 600979 ) on Monday April 27, 2015 @07:22PM (#49565015)

        When you load a javascript library the browser has to allocate memory to every function in the library even if they are never used and most web sites are using dozens of javascript libraries. While this is ok on a desktop, on a tablet - which has much less memory - it means you only have enough memory to have one web page open at a time. Some web pages are so infested with javascript libraries they cause the tablet browser to crash. And they are just displaying static text and images, something that doesn't require javascript.

      • by rch7 ( 4086979 )
        What you will learn about such libraries hard way is that they come and go, and when you come later and see the code that is a mess of few half-maintained half-abandoned libraries that were very cool & popular just few years ago, you are lost. And than suddenly you need to adopt to changing client base and your library maintainers didn't released new version and or are not interested in fixing bugs quickly. What is your plan then? Fork your own version? Fine, but the library tries to be super-universal
        • by unrtst ( 777550 )

          Wow... so your solution to avoiding the common case of re-inventing the wheel and having "a mess of implementations of half-maintained half-abandoned libraries" is to... wait for it... use "custom in-house libraries"? Even worse, those will only do "what is required, nothing more, and won't cover special cases that you don't use" (at that time for that app).... so when you try to get all your various in-house incantations using the same incantation, you'll simply have to rewrite... well, everything. Good lu

      • You've posted several reasons why it might be acceptable to choose jquery. However, I think there's an even more compelling reason for why you probably SHOULD use jquery (unless you can come up with a really compelling reason otherwise). I posted about it nearly a year ago: http://mobile.slashdot.org/com... [slashdot.org]

        Here is the most relevant part from my previous post:

        You know what I like to actually optimize? Getting things working correctly. Think jquery is a waste? Well, lets look at that fading example above. Pr

      • Sure all the points made by Vanilla-JS are valid, but using the more convenient syntax than a library provides is ridiculous.
    • by dissy ( 172727 )

      Personally I just make sure to compile jQuery using VanillaJS to take advantage of all the speed VanillaJS offers!

  • meh (Score:3, Informative)

    by XO ( 250276 ) <blade,eric&gmail,com> on Monday April 27, 2015 @04:10PM (#49563641) Homepage Journal

    jquery makes an absolute mess out of javascript. Much of it involves DOM manipulation, which is something you generally want to avoid doing as much as possible. It's a pain in the ass to read, has a nasty learning curve, and it's slow as fk. Don't bother, unless you need to operate on existing jquery code, or have some other very specific reason to use it or interact with code that uses it.

    • Re:meh (Score:5, Informative)

      by jandersen ( 462034 ) on Monday April 27, 2015 @04:45PM (#49563933)

      It's a pain in the ass to read, has a nasty learning curve, and it's slow as fk

      Eh? It took me all of a few days to read through one of the many reasonable books about jQuery, and I found it makes it a whole lot easier to make sense of the DOM. In a browser, what else is there to JavaScript, other than messing around with the DOM? Of course, I only use JavaScript on the client side, for the server side I use J2EE and GlassFish. jQuery is perfect for my use and very, very easy to learn.

    • Re:meh (Score:5, Insightful)

      by meustrus ( 1588597 ) <meustrus@NospAm.gmail.com> on Monday April 27, 2015 @04:48PM (#49563953)

      Much of it involves DOM manipulation

      Yeah? Much of jQuery is about DOM manipulation. If you don't want to make a hole, don't use a drill.

    • Re: (Score:3, Insightful)

      by halivar ( 535827 )

      I agree in the main that DOM manipulation is the root of all JS sin, but the list you provide is not my experience as all. Like all code, well-written JS+jQuery ought to be self-documenting. Again: caveat is well-written. The learning curve is no steeper than figuring out JS's own native esotericisms. Yes, jQuery is slow as fuck. $('#something') is something like thirty times slower than document.getElementByID(), BUT when you are in the realm of milliseconds I will trade those extra keystrokes because I'm

    • So if you are trying to avoid manipulation the DOM than avoid using the DOM manipulation library. Got it.
    • Nasty learning curve? Really? I don't know JS, but I needed something to do simple dynamic DOM manipulations for an in-house web page. Couldn't do it with CSS. JQuery was easy to learn and it got the job done.
  • by Needs2BeSaid ( 4062029 ) on Monday April 27, 2015 @04:14PM (#49563659) Homepage
    No. jQuery is bloated by their desire to make sure your pages are compatible with ancient Microsoft browsers.

    Also, jQuery allows developers to be very lazy. Example: Many sites bring back JavaScript in their AJAX returns. Did you know that jQuery uses EVAL to process any JavaScript returned via AJAX?

    jQuery UI is a horrendous memory and performance hog. There are billions of JavaScript code examples to perform the individual functions of jQueryUI without forcing your customers to download that monster.

    Don't be lazy.
    • Re: (Score:2, Insightful)

      Im not being lazy, im being productive. jQuery helps you get things done quickly. Could I get everything I needed done without it? Of course, but when I can get things done much faster with it, I will use it.

      • Im not being lazy, im being productive. jQuery helps you get things done quickly. Could I get everything I needed done without it? Of course, but when I can get things done much faster with it, I will use it.

        You could get things done faster with jQuery so you have more time to be on /.? :-D

    • Re: (Score:2, Insightful)

      by Anonymous Coward

      There are billions of JavaScript code examples to perform the individual functions of jQueryUI

      Billions of code examples to search and sort through that may or may not actually work, instead of one set of code that does most of what I need right now? And this is supposed to be an argument against jQuery?

  • by Ungrounded Lightning ( 62228 ) on Monday April 27, 2015 @04:14PM (#49563663) Journal

    A site may wish to continue using JQuery because some of its clients are using older browsers that don't support the new features that allegedly obsolete JQuery code.

    Drop the JQuery code and you drop those customers. Develop future code without it and the pages with the new features won't perform with people using legacy browsers. And so on.

    I've seen similar things happen over several generations of web technology. Use care, grasshopper!

  • Comment removed (Score:5, Insightful)

    by account_deleted ( 4530225 ) on Monday April 27, 2015 @04:14PM (#49563669)
    Comment removed based on user account deletion
  • Yes, at least until IE 6, 7, 8, etc. are truly dead. Our browser stats show that enough people are still using non-evergreen browsers that we are required to still support them. As far as I can tell the higher ups won't let us drop them until they are down to 0 hits a month. Sigh.
    • Must be nice.

      In my world html5 comes in 2020 when Windows 7 Goes EOL

    • Re:IE 6 (Score:4, Funny)

      by Lodlaiden ( 2767969 ) on Monday April 27, 2015 @07:22PM (#49565011)
      $20 and I'll turn off my regression suite that checks if your site is still IE6 compatible.
  • Uh... yes (Score:4, Insightful)

    by ZipprHead ( 106133 ) on Monday April 27, 2015 @04:23PM (#49563747) Homepage

    That is, If you like frameworks that are bug free, extensively tested, universally known and hide a lot of the weirdness between browsers and browser versions providing a consistent interface, then yes, definitely learn it, it takes a lot of pain away.

    If you like pain, or always want to use the shinny new fancy thing, or want to learn all about IE9 and Opera edge cases. Then don't use it.

  • by oh_my_080980980 ( 773867 ) on Monday April 27, 2015 @04:23PM (#49563749)
    So yes you need it to do the stuff that SharePoint doesn't do.
  • Never learned jQuery (Score:2, Informative)

    by Anonymous Coward

    I've been using Javascript for 15+ years and never seen the reason to learn jQuery.

  • by Lobo42 ( 723131 ) on Monday April 27, 2015 @04:28PM (#49563793) Journal

    I don't know that I'd start a new project in it, but jQuery has permeated the web to such a degree that I don't know if you *can* be a front-end web without being vaguely aware of it. It's worth *knowing about* but there isn't much to *learn* about it. It's a library for "querying" the DOM the way you do in CSS; that's why it became popular -- that particular task used to be difficult, even though now it's part of the DOM [mozilla.org]. I still use it for Ajax requests, mainly because the syntax is easier for me to remember than native JS. But most of what jQuery made easy is already easy in bleeding-edge browsers and frameworks. The rest - promises, events, animations, ajax - are sort of "helper fluff" that are also better done in other libraries, or native JS/CSS at this point.

    TL;DR - Yes, you should learn it, but don't go out of your way to focus on it. If you understand modern JS & DOM techniques, then you'll be able to figure out jQuery easily when the day comes that you need to debug/modify/replace it.

  • Yes... (Score:3, Insightful)

    by hyperar ( 3992287 ) on Monday April 27, 2015 @04:31PM (#49563821)
    As long as the web is used to publish extremely complex apps that should not be on the web, yes. Web is for video playback, reading news and blogs, Business app?, desktop, using web services.
    • Re:Yes... (Score:5, Funny)

      by xxxJonBoyxxx ( 565205 ) on Monday April 27, 2015 @04:37PM (#49563865)

      >> Web is for video playback, reading news and blogs, Business app?, desktop

      And how long have you been out of work?

    • Web is for video playback, reading news and blogs

      You forgot to mention the cat pictures.

    • Re:Yes... (Score:4, Insightful)

      by Literaphile ( 927079 ) on Monday April 27, 2015 @04:46PM (#49563943)

      Web is for video playback, reading news and blogs, Business app?, desktop, using web services.

      2001 called, it wants its antiquated attitude back. The web evolves: deal with it. You bitching about what the web is now isn't going to make us all suddenly go back to "video playback, reading news and blogs".

    • Re:Yes... (Score:4, Funny)

      by dissy ( 172727 ) on Monday April 27, 2015 @05:57PM (#49564473)

      Web is for video playback, reading news and blogs, Business app?, desktop, using web services.

      I thought the web was to add inline images to your gopher menus :P

    • If you develop a native app people will use everywhere, you probably need these version:

      1. Windows
      2. Linux
      3. iOS
      4. Android

      And then you need to convince people to download and install your software, because it is not malicious. OTOH, with a web app they just need a browser.

      Native apps may be a better solution when you are doing a custom application for a specific business, and all their employees have Windows desktops or laptops.

    • Business app?, desktop, using web services.

      Good luck getting users of anything but a Mac to run an app developed on and for a Mac. Web is more cross-platform than native.

  • Yes (Score:3, Insightful)

    by Anonymous Coward on Monday April 27, 2015 @04:36PM (#49563863)

    JQuery as a framework is, frankly an utter joke. However, as a utility library it's invaluable. Learn Angular, React, or some other modern framework, and lean on JQuery for things those frameworks don't do. Simple example: Ever try to submit a from from an AngularJS controller? Yeah, not doable. Add 2 lines of jQuery? Done! So yes, learn it, and use it where it fits.

    • by narcc ( 412956 )

      Don't use just one bloated library, use two!

    • by erlando ( 88533 )

      Simple example: Ever try to submit a from from an AngularJS controller? Yeah, not doable. Add 2 lines of jQuery? Done! So yes, learn it, and use it where it fits.

      If you're not able to submit a form in Angular you're not using the framework correctly.

    • by olau ( 314197 )

      The reason why it's not good as a framework is probably because it's not a framework, and never intended to be.

      Perhaps you're thinking of jQuery UI which is not jQuery, and not really a framework but more like a set of somewhat similar widgets.

  • I recently started putting together a web app for someone and I wanted it to design it primarily for mobile.
    Looking at google analytics of several web sites I see the majority of web traffic is mobile.
    So if JQuery is bloat, unnecessary, outdated and "features are present in [modern] browsers" what should I be using instead of:
    http://jquerymobile.com/
    This seems like the perfect solution to me?

    • I don't personally like jquery mobile because I don't like one-page apps, or indeed, any framework that dictates how I organize my application. Though it may be an unpopular opinion, I dislike the whole convention over configuration theme that's popped up during the RoR popularity phase. Not only can my IDE write out any boilerplate, but I can also search for the linkage, and all that without making 80% of my application easy at the expense that 20% will be hard or impossible.

      Now, most of the applications

  • I don't get it (Score:5, Insightful)

    by quietwalker ( 969769 ) <pdughi@gmail.com> on Monday April 27, 2015 @04:41PM (#49563887)

    JQuery is just encapsulating some primarily dom-related javascript mainpulation routines with the added bonus that they try to eliminate browser differences. So, when you're saying that the browser provides features that jquery was needed for, you're really saying that the browser does things that javascript is no longer needed for.

    I'm just not seeing it though. With pure HTML & CSS and a fancy new browser, can I:

    Write ajax requests and parse and conditionally apply the results to various page elements?
    Dynamically add and remove elements?
    Perform liquid resizing based on a layout approach with glue elements and fixed-but-scalable areas - that is dependent upon the size of other elements rather than explicit browser viewport height/width?
    How about perform custom input box validation?
    Maybe set the value of a text box only when a value in a linked select box is changed?
    Pop up a dialog when a button is clicked?
    Start an image upload when you drag an image over a browser region?

    In the age of ever-closer-to-desktop-application websites, I'm only seeing more and more use of javascript frameworks - of which jquery is one - and frankly I don't see how anyone could do without it. Maybe if you're making static brochure sites, I suppose, but then you weren't using javascript for that anyway.

    Maybe the original poster meant to say "is it worth learning jquery instead of another framework or library" ? Otherwise I can't see anyone who actually creates web applications for a living even asking this.

    • Agree with this. Most of the people in this thread seem to spend their time reinventing the wheel as opposed to using libraries for what they are. Maybe certain aspects of JQuery aren't necessary anymore with modern browsers, but for the most part it offers some pretty awesome tools for getting your work done. And I'd prefer to spend more time developing unique stuff for my app as opposed to inventing generic stuff that JQuery already does fairly well.

    • by LDAPMAN ( 930041 )

      Yes...

    • by guruevi ( 827432 )

      Yes, you can (jQuery just encapsulates a lot of 'common' JS tricks). But the post is advocating for the latest framework/library du jour which does the same thing, sometimes faster, sometimes with more options or less code but the same nonetheless. jQuery is fine for what it does. I've tried using Angular, Backbone etc but unless you have something you can build something from the ground up around those libraries, they're quite useless or require a lot of custom implementation when using existing data sourc

  • 5 Minutes (Score:5, Insightful)

    by wisnoskij ( 1206448 ) on Monday April 27, 2015 @05:05PM (#49564101) Homepage
    It takes like 5 minutes to learn to use Jquery, it is used in 90% of all current websites, and is still one of the best if not the best library for dynamic DOM manipulation and has incredibly easy to use ajax requests. I cannot imagine creating a dynamic website without it.
  • Learning JQuery is just learning CSS. CSS is pretty important to know, if you want to do anything with the web.
  • If you need to support IE 7, definitely. But if you don't, you what? Use it anyway. The best of jQuery has been brought into the JavaScript language itself and other libraries. But jQuery still makes a lot of little things easier.

    You could use the new querySelectorAll functionality in JavaScript, but learning that teaches you the basics of how to use jQuery. Also, I think jQuery still has a few selectors that aren't in querySelectorAll . Furthermore, querySelectorAll is very long to type.

    You can use a

  • jQuery is a crutch. (Score:4, Interesting)

    by extranatural ( 937162 ) on Monday April 27, 2015 @08:31PM (#49565345)
    I saw a very insightful & funny talk on this subject last year. The very clever Josh Broton lays out exactly why jQuery has become an excuse not to do it right the first time. Basically it comes down to this:

    A few facts about latency and user behavior: "...250 milliseconds can be the difference between a return customer and an abandoned checkout cart." "...every 100 milliseconds of latency resulted in a 1% loss of sales." "...lose 20% of their traffic for each additional 100 milliseconds it takes a page to load."

    The average overhead jQuery adds to a website: "... add roughly 150ms to 1 full second of load time..."

    He goes into many other good reasons too, it's well worth a read.

    Slide here: https://github.com/joshbroton/... [github.com]
  • I recently coded a highly dynamic webpage using jquery and to my surprise it ended up working in all versions of IE, all versions of Firefox, and Chrome on Android. This greatly enhances the availability of my site. How do I get such compatibility for free without using jQuery?
  • Does most of what i ever wanted jQuery for.
  • I find myself relying less and less on jQuery and more and more on AngularJS and native HTML5/CSS3 (+Bootstrap), (and Lodash for the FP bits). The AngularJS stuff encapsulates the DOM manipulation more cleanly and HTML5/CSS3 has gotten powerful enough to do declaratively what you used to have to do programmatically. However, it is still handy to know some jQuery, particularly to shim the code a bit around the edges of Angular and for various programming tasks. jQuery can make code cleaner, too, though it

"Protozoa are small, and bacteria are small, but viruses are smaller than the both put together."

Working...