3

I'm currently on the fence about using or not using jquery. I've spent hours researching the pros and cons of using jquery (or any library for that matter).

One of the big selling points of jquery is that it frees a developer from worrying about browser incompatibilities. I've tried to find any documentation on exactly which incompatibilities it overcomes. So far I haven't found any. Can anyone help me out with this.

wsanville
  • 37,158
  • 8
  • 76
  • 101
pd1138
  • 63
  • 6
  • 5
    [This question](http://stackoverflow.com/questions/2599020/what-are-the-typical-reasons-javascript-developed-on-firefox-fails-on-ie) includes [an excellent answer](http://stackoverflow.com/questions/2599020/what-are-the-typical-reasons-javascript-developed-on-firefox-fails-on-ie/2599388#2599388) that details many items. – user113716 Jan 05 '11 at 04:37

5 Answers5

2

You should become very familiar with www.quirksmode.org.

It is an excellent browser-compatibility resource.

user113716
  • 318,772
  • 63
  • 451
  • 440
  • 1
    I give you credit for the David Lee Roth avatar, but seriously, he was 1000x better in Van Halen, his solo stuff is just...meh. Eat 'Em and Smile? You can't even hear Vai in the mix he's totally buried. – wsanville Jan 05 '11 at 04:49
  • @wsanville: I wondered if anyone would recognize it. :o) Yeah, we can't have an actual musician stealing the spotlight from Diamond Dave, now can we? – user113716 Jan 05 '11 at 04:53
  • Oh yes, I've been visiting that site for almost 10 years. I've never seen any listing of jquery compatibility fixes on the site. Is it there and I'm just too blind to see it? – pd1138 Jan 05 '11 at 04:53
  • @pd1138: If you've been visiting that site for 10 years, then you should be familiar with browser compatibility issues in general. jQuery aims to fix those issues. Instead of providing an entire list of what jQuery does fix, perhaps you need to ask about a specific compatibility concern. – user113716 Jan 05 '11 at 04:57
  • 1
    @patrick: lol I recognized it a while ago, but didn't decide to comment until now. I have my fingers crossed for a Van Halen/Dave reunion in 2011. – wsanville Jan 05 '11 at 04:57
  • Perhaps my question is too broad, I guess I'm looking more for DOM issues, but really any incompatibility be it CSS, DOM, or XML would be nice to know. – pd1138 Jan 05 '11 at 05:19
  • @pd1138: Yeah, it's a little tough to answer. A person almost needs to embrace it as a whole. Sometimes you may use it to do something that doesn't require a compatibility fix, but rather provides a more convenient API. I think a lot of people use it to do absolutely everything. Since you're familiar with the DOM, you'll probably have a natural sense of when/where it makes sense to back away from it. – user113716 Jan 05 '11 at 05:28
  • ...Your example of using `className` is a good one. It is cross-browser compatible, and you should still use it in some circumstances. On the other hand, sometimes it's just nice to do `$('div.someClass').addClass('someOtherClass');` to add a new class to a bunch of elements. – user113716 Jan 05 '11 at 05:29
1

I don't think you'll find an actual list, but you can browse the source code and read the comments about certain code solving certain browser inconsistencies.

Examples

// check if target is a textnode (safari)
if ( event.target.nodeType === 3 ) {
    event.target = event.target.parentNode;
}

// safari subtracts parent border width here which is 5px
this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
Community
  • 1
  • 1
alex
  • 479,566
  • 201
  • 878
  • 984
0

To name a few, jQuery implements selecting DOM elements by class name in browsers that do not support the method document.getElementsByClassName (which is IE 8 and previous). So for example, you can select all of the elements with the class myClass with the following: $('.myClass').

jQuery has several useful wrappers around the XMLHttpRequest object, which has varying support across browsers (see here).

Also, jQuery takes care of some differences when it comes to DOM manipulation, like modifying attributes of elements or adding classes to elements, which as I recall, is slightly different in Firefox/IE.

wsanville
  • 37,158
  • 8
  • 76
  • 101
  • As XMLHttpRequest object I'm assuming that you mean the fact that IE 7 and below use an activeX object. Is there anything else? – pd1138 Jan 05 '11 at 04:57
  • I've used the className property to add or change an element's class attribute values for years with no issues on any browser (at least so far), exactly how does jquery help here? – pd1138 Jan 05 '11 at 05:02
  • With regard to adding classes to elements, there is an IE6 issue where it will fail if you do `el.setAttribute('class','someCls');`. Instead it requires `el.setAttribute('className','someCls');`. Perhaps that's what you were thinking of. – user113716 Jan 05 '11 at 05:40
  • el.setAttribute('class','someCls') WILL NOT work in any browser. class is a javascript reserved word so it is illegal to use it – pd1138 Feb 20 '14 at 20:27
0

Few of the things that i know are listed here:

IE has a different Event Model than Mozilla and some of the Gecko Borwsers which implement DOM2 Event Model. jQuery does a good justfication of provding browser independence by introducing jQuery Event Model.

IE does not supports css3 whereas Mozilla has support for css3. The jQuery selectors are independent of browsers selectors behaviour.

Mozilla does support method like document.getElementsByClassName however ie doesnt. But jQuery class selector prvents this issue as well.

IE and Mozilla has different properties for floats for ie its styleFloat for Mozilla its cssFloat jQuery gives us flag for cssFloat to uniquely determine it.

jQuery also has another flag jQuery.boxModel which tells users which boxModel your browser is supporting IE quirks mode or W3C compliant.

sushil bharwani
  • 29,685
  • 30
  • 94
  • 128
  • Thanks, this is the kind of stuff I'm looking for. The event models used in browsers can on occasion be messy when you're trying to roll your own event, trying to use the target/srcElement property, plus others. You mentioned css3, do you mean the selectors only or do mean setting/getting css3 properties too? – pd1138 Jan 05 '11 at 05:34
0

I have been working with jQuery for a while now and i can tell that the 26kb that it weights is a really small price, and like many other files only needs to be downloaded once (after that it gets loaded from the cache).

1. [Huge list of plug ins]

There are many plug ins for different solutions: galleries, validation, ajax, file handling, etc. Also you can use plug ins to [fix CSS problems]

2. Browser compatibility

Although i was not able to find a documented list of the fixes jQuery applies, you can always go over [the source code], it is very well documented and divided so you can see what happens when.

3. Consistent

While you work on different projects, if you keep using a library, you will learn more from it each time and work faster.

4. Community

jQuery probably the biggest in javascript libraries, and that comes with a lot of advantages like support, tutorials and plug ins.

5. DOM Manipulation

jQuery sintax makes it very easy to manipulate the DOM, instead of document.GetElementsByTagName("tag") you can do $("tag")

Bottomline

I can tell jQuery has saved a LOT of time for me, and made things easier to deal with, i would totally recommend using a library.

amosrivera
  • 26,114
  • 9
  • 67
  • 76