Chicago JavaScript Meetup Group Message Board Chicago JavaScript Meetup Schedules and Logistics › Man my head is starting to hurt

Man my head is starting to hurt

Matt K.
user 7926628
Chicago, IL
Post #: 2
Long story short, as I said at the meetup, I've been tasked with addressing our cross browser issues. My head is hurting after 2 weeks of this. I have one friend who does Java development that champions Dojo. Yet Jquery seems to have the better community and cleaner resulting code (although it seems DOJO can do that too). And our web framework, WebObjects, has Ajax integrated into it but at the time prototype was big so it's based on that.

And I still don't know what the errors/bugs are I'm supposed to be fixing.

So I'm looking to start a discussion for some insight on which way to go.

No I have not forgotten about JavascriptMVC but I'm holding off on that for now.

A former member
Post #: 4

The principal difference between the way jQuery and anyone else addresses the cross-browser issues is the way they detect a need for different behaviors. Most frameworks do browser sniffing, that is parsing the User-Agent header and looking at the navigator object. jQuery proposed to test for implementation of specific features at the run-time instead (it will be fully converted to this approach at jQuery 1.3).

Both approaches seem to have very solid pros and very important cons. In fact that was, IMHO, the most heated discussion at AJAX experience. I personally like John Resig's (jQuery) approach, but I see Dylan's (DoJo) points he made during the debate. Truth is that the test for each approach happens when browsers are updated - and how the applications running jQuery vs. others will react.

A little bit from a different angle:

My experience was that cross-browser compatibility is handled well by all frameworks one way or another, as it is a matter of their survival. When selecting a library other considerations were more interesting for us. I would hate to switch the topic to an often sensitive area, but it may make sense for you to look at a framework selection from a more holistic cost/benefit perspective.

Justin M.
user 6038412
Libertyville, IL
Post #: 1
Most libraries do browser sniffing only where it makes sense. I talked about this a lot with the Dojo team, and from my own personal experience, what resig said is a pipe dream. There are things that can't be done without an XHR request coming back. For example, though IE7 supports XMLHttpRequest, you should still be using new ActiveXObject("Microsoft.XMLHTTP"­). This is because in a few cases, IE7 doesn't work. The only way to detect these cases would be to use XMLHttpRequest, see that it doesn't work, and switch. Unless someone came up with a way of inspecting these problems with XMLHttpRequest (which no one on the dojo team could figure out), there is no way to do this. Setting headers is another example of this problem. If you want it to be fast, limited browser sniffing is probably the best bet.

Here are some of the big differences:

Dojo and YUI are protected by the Dojo Foundation, and Yahoo - like Apache. Only people who have signed something saying their code is theirs can submit. This removes the chance that someone's code gets stolen, finds its way into jQuery, you use jQuery, and they sue everyone who uses jQuery. This can't happen with Dojo+YUI.

Playing well with others
Prototype writes to the global namespace in many places. It also writes to native object prototypes (this allows things like capitalize() to be called on strings). This means it does not work as well with other libraries. YUI, as far as I know, is the only library (other than JavaScriptMVC) to be protected against libraries that add to object.prototype. This basically means for something like:

for(var a in b){if(!b.hasOwnProperty(a)) continue; .... })

This is a big reason why I do not recommend prototype.

All of the big 4 has a big community. Though much smaller, JavaScriptMVC has a chat client on every page where I respond to every 2 seconds. And, I guess you also know me. smile

They are all pretty good. Though I like jQuery / Prototype / YUI / Dojo in that order.

Finally, the most important consideration ....

What you are building
What you are doing with your application matters a lot. If you are building something big and complex, do NOT USE JQUERY! Though if it is simple, use jQuery.

If you have a complex application, anything like a google app (Reader, Docs, Gmail), you will almost certainly not be able to build it effectively with prototype or jQuery. The big reasons are compared to Dojo / YUI, jquery ...

has no event delegation - this will make your code a mess, slow, and likely leak memory in IE6
has no build process - you want to be able to easily join files to speed download times
has inferior testing - YUI's is really good, Dojos is still much better
leads to messy code - people get addicted to putting everything in $ and all in one big 'closure ball'. YUI and Dojo won't let you get away with this.

People like jQuery, for good (and bad) reasons for its chaining, letting you do:

But don't that make your mind up because all the other libraries have plugins that can do the same thing with their selector.

If you are building something big, and not using JavaScriptMVC, my first choice would be Dojo.

Dojo has quite an impressive list of 'approved' extensions that can't be found anywhere else -, RSH, Perserver. They have people who really push the limits of JavaScript at Sitepen.

Thank you for considering JavaScriptMVC! But JavaScriptMVC isn't a library in the sense that the other tools are. It's more based around providing JavaScript's missing toolset and forcing developers to write maintainable JavaScript.
You can use it with any other library. It does the things most other libraries don't:

Event delegation, documentation, error reporting, compression, templates, testing (even server side).

Though Dojo has compression+templates, ok but not great server side testing.
Powered by mvnForum

Our Sponsors

  • Bitovi

    The maintainable Javascript experts. We organize and speak at JS.Chi.

  • Enova Financial

    An adventurous Ruby/Javascript shop. Providing a room, pizza, and beer.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy