SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Why discourage using jQuery?

    Hi guys,

    I noticed many of you here discourage using jQuery?
    As far as I know the purpose of jQuery is Code Less, Do More.

    So please can you guys explain why you prefer using pure JavaScript than using jQuery?
    I want to know the reasons why?

    Thanks in advance.
    Quality codes are optimized and tested...
    Click here for inspiration..

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by solidcodes View Post
    Hi guys,

    I noticed many of you here discourage using jQuery?
    As far as I know the purpose of jQuery is Code Less, Do More.

    So please can you guys explain why you prefer using pure JavaScript than using jQuery?
    I want to know the reasons why?

    Thanks in advance.
    Primarily it's because the people providing help and assistance here should not promote a personal preference towards libraries. This is why you don't find people pushing YUI or Dojo or MooTools etc. If anyone was to do so, there would be umbrage from the general community, and the same applies to jQuery too.

    There can also be times when you may want someone to realise that what they're wanting to achieve may be easier to do by using a certain library, or external resource. By all means mention that, but if you do then you must approach that idea with the understanding that they may not want to take that idea onboard.

    If someone says that they are currently using jQuery, or some other library, that then is a good time to start applying techniques from that particular library.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,863
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    To be able to use JQuery (or any of the other frameworks) properly you need to have an intermediate level knowledge of JavaScript first. Most of the people having problems with the frameworks are having those problems due to too little knowledge of JavaScript itself prior to trying to use a framework built on top of it.

    Yes JQuery (and the other frameworks) allow you to write less code yourself and do more but only because the framework provides the JavaScript code to do the rest for you. Only once you at least understand the concepts of how to do each of the tasks for yourself using ordinary JavaScript does it make sense to substitute calls to existing functions that contain the code to do it for you. Only at that point can you properly work out which calls to use for what and were using the framework would actually result in writing more code.

    I have seen beginners use JQuery with twenty line of code they have written themselves to do JQuery calls where six or seven lines of JavaScript without JQuery calls could achieve the same final result much faster - making JQuery for them - write more to do less - and so defeating the entire purpose of JQuery in the first place.

    There's nothing wrong with using JQuery or another framework to reduce the amount of JavaScript that you write - as long as you know enough JavaScript to use it properly. Most people having problems with JQuery are having the problems due to trying to use it prior to learning enough JavaScript to know how to use it properly. Therefore the appropriate advise in most cases where people are having JQuery problems is to learn more JavaScript.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,301
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by solidcodes View Post
    why you prefer using pure JavaScript than using jQuery?
    jQuery is JavaScript. The jQuery motto could just as accurately have been Code Less, Download More. To use jQuery, the browser has to download a big JavaScript library (prewritten code). So before using jQuery, it's worth asking if it's really needed, or if it's really more efficient. You sometimes see people using the entire jQuery library to add two numbers together—something you can do with one line of JS. Another way of looking at it is this: if you need a new hammer, should you go out and buy a whole hardware store?

  5. #5
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,615
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by ralph.m View Post
    jQuery is JavaScript. The jQuery motto could just as accurately have been Code Less, Download More. To use jQuery, the browser has to download a big JavaScript library (prewritten code). So before using jQuery, it's worth asking if it's really needed, or if it's really more efficient. You sometimes see people using the entire jQuery library to add two numbers together—something you can do with one line of JS. Another way of looking at it is this: if you need a new hammer, should you go out and buy a whole hardware store?
    In all fairness, the library isn't *that* big. Version 1 is 90KB and version 2 is 80KB.

    If download speed is an issue, it's sometimes good practice to put all the javascript files near the end of the body to led the HTML and CSS load first, then the javascript.

    To echo what the others have said, Javascript frameworks have their place, and you just need to get enough experience with javascript in order to determine when or when not to use the features available to you in a framework.

    Typically, I use javascript frameworks for (complicated) DOM retrieval, animation/transition effects, and AJAX. All of these things are implemented in slightly different ways across browsers, so it's handy just to write code once using a framework to essentially do the same thing in all browsers.

    One of the reasons why jQuery is one of the frameworks you typically hear about is because it is one of the most active javascript framework projects with fairly frequent releases and updates.

    However, with jQuery, it's important to note that version 2.x has dropped IE6-8 support. Version 1.x still has IE6-8 support.

    Here's a comparison of the various major frameworks that are available:

    http://en.wikipedia.org/wiki/Compari...ipt_frameworks
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •