Which Javascript library?

Status
Not open for further replies.

BlackHex

Ars Tribunus Angusticlavius
9,638
Subscriptor++
I've been thinking about doing some UI development with Javascript/html/ajax.

There seem to be a bewildering number of different toolkits and libraries out there [extjs, mootools, angularjs, dojo, knockout, requirejs, jQuery, to name just a few]... and it's not clear to me which combination is the right way to get started.

I'm looking to build a single page app (i.e. everything will be done using # based urls, json fetches from the server, and locally cached data) with some quite complex standard and custom UI elements.

Can anyone shed any light on what the libraries I should really be investing my time in learning?

My Assumption is: RequireJs, jQuery, angularjs, and extjs but I'm rather guessing since they all seem to overlap so much.

Thanks.
 

smoofles

Ars Tribunus Angusticlavius
8,020
Subscriptor
jQuery has shit tons of docs and plugins and such and will only start to irritate you if you are good at JavaScript and your needs outgrow the plugins. Backbone.js with jQuery might be useful if you have a complex(er) app in mind.

Which reminds me I need to check out how Batman.js developed in the past months…

Edit: Oh, and you can just use zepto.js instead of jQuery if you’re on mobile and then tell me whan an awesome done-in-10-minutes logo it has. :D
 

smoofles

Ars Tribunus Angusticlavius
8,020
Subscriptor
Based simply on that extjs might be a good choice. But it depends on the app’s complexity and how easy a time you have doing custom JS widgets. If the app is small and you want to deploy on mobile and you feel comfortable with JavaScript, I would suggest a library that handles the data manipulation/models/caching (a la Backbone.js or Batman.js). The reason being mostly that a lot of custom stuff will have you blowing your top at the various restrictions or idiosyncracies of "big" frameworks as soon as you start pushing their limits.

That’s just a rough guess around knowing what you’d like to do. There’s a lot more to consider if it’s a high profile app for a Fortune 100 company than if it’s just a hobby app of yours.
 

tinyMan

Ars Tribunus Angusticlavius
6,149
Subscriptor++
Look at the Extjs examples and see if it looks like it can do what you want out of the "box" with the built-in widget set. If it can, its probably the easiest way to get started. Its a fantastic toolset for building complex data-heavy applications.

Grabbing a demo of their GUI tool (Sencha Architect) and using that to throw together the "bones" of the app can be a big time saver. If your app fits there model, ExtJs is probably the fastest way to get a complex Web Application out the door.

Overall, I really liked EtxJs, but we couldn't use it because it did not cover all the ground we required, and when you have to start changing stuff under the covers, ExtJs becomes troublesome.

If you _know_ that ExtJs isn't going to get you there, I'd suggest looking at Twitter Bootstrap + jQuery + BackBone and probably a few other libs. Solutions in this group tend to be commonly combined and play very nice with each other, with lots of examples and demos.

No matter what you end up doing, I'd really stop and think for a moment about how you want to handle the "back button navigation" and "bookmark-ability" of your application up front, because getting those right _after_ you have a bunch of code buried in callback functions is a nightmare.
 

BlackHex

Ars Tribunus Angusticlavius
9,638
Subscriptor++
tinyMan":1sa9z4to said:
No matter what you end up doing, I'd really stop and think for a moment about how you want to handle the "back button navigation" and "bookmark-ability" of your application up front, because getting those right _after_ you have a bunch of code buried in callback functions is a nightmare.
That was why I was planning on using # based urls. Are you sugesting there is more that I should be looking at?
 

tinyMan

Ars Tribunus Angusticlavius
6,149
Subscriptor++
# or #! Urls have some serious issues, as described here.

The crux of the issue is that your server will never see any part of the url after the hashbang, leaving the delivery of those pages entirely up to your JS stack. For some use cases, this is not a problem. In other cases (like SEO or sharing links) this might not be so acceptable.

There is a lot more to think about, as URLs are so important, but others have said it better than I could.
 
++ to tinyMan, the first thing you need to figure out for a single-page app is how you are going to handle URL's. jQuery alone is seriously inadequate for this purpose. Ideally you want to not think about this, and just write your app - something like Backbone, Spine, probably extJs will handle this for you as part of their router. I think the current ideal is to use the PushState API in browsers that support it, and fall back to a hashbang type thing if you really have to for browsers that don't. But like I said, you don't want to deal with that, you want to find a library/router that will do it for you. So you should figure it out before you get too far in, because as others said it's hard to "fix" later.
 
"Seriously inadequate" might be a little over the top, but every "rich" or "single page" app I've worked on that relied mostly/solely on jQuery, state management and sync ended up turning into a huge pain. I've used jQuery BBQ and jQuery Address and neither of them is really as hands-off as I'd like. I am really looking forward to using something like Backbone or Spine on my next project of this type as I think a more full-featured client side library will probably help my frustration quite a bit.
 
aliftedlorax":2p1axmn4 said:
BlackHex":2p1axmn4 said:
At least all of: buttons, grids, dropdowns, calendars (picker, agenda, and outlook style), lists, charts (bar, pie, and custom), image maps, text-boxes.
I think you want the Dojo Toolkit with this amount of enterprisey stuff. They've largely fixed their documentation issue from a few years ago.

Say it with me: Web applications are not Windows XP GUI apps. It looks like the use case for their demos was "Give me something that looks like Swing except doesn't perform as well and is on the internet". Painful.
 
vherrera0079":2ijl9q8y said:
Web applications are desktop GUI apps now. That's the way it is.

I agree. But they shouldn't try to pretend they're GUI applications from Windows XP. The Demo of Dojo Tools even captures right clicks to change the context menu. You can write an effective HTML/JS Desktop App without making it look like a desktop app. Dojo Tools seems to think that's not the case. You can do what Dojo Tools does with Bootstrap except you'll look like you've got a UI that was written this decade.
 
smoofles":1ck1ur7z said:
vherrera0079":1ck1ur7z said:
Web applications are desktop GUI apps now. That's the way it is.
Uhm, no? :p

I'm not saying Dojo is pretty or anything...
But that level of interaction is expected of web apps these days. Google Docs, anyone? So seeing stuff like the right click taken over for context menus is not shocking to me at all.
 

mormy

Seniorius Lurkius
38
ominous":1kiuehmn said:
I say screw JavaScript and write it all in Dart, escape the Prototype devil!
And have it compiled to underperforming JS... ?
Or just say to the users, well, you gotta install Chrome... That approach is especially effective if you're working for a bank, or some other large corp.

Three letters... YUI... best framework, best docs... IMO... jQuery is not that useful if you want to write JS, and you have to use 3 separate libs to get the full stack (data, utils and UI... meaning Backbone, Underscore and jQuery)...

So YUI... or Dojo... or even Prototype...
 

3.3volts

Ars Praetorian
478
Subscriptor
I've been doing some trivial work in AngularJS, and I've really enjoyed it.

It's the first JS template system that I really got.

My blog is currently implemented using it. I still have to undertake some of the messiness to do something on the backend to accommodate Google's crawlers, but other than that it's fantastic and took me less than 4 hours to implement the whole blog from scratch, something that I'd be hard pressed to do even in something like Django. I can host the whole thing statically as well, which means I can throw it up on Amazon S3 for pennies and not have to configure any .htaccess files.

To be honest, learning jQuery is worth it simply because it's an industry standard at this point. A lot of people kind of sneer at jQuery at my Javascript meetup group, and call it bloated, but with a CDN literally every visitor is going to have it cached anyways, and I'm sure the browsers intensively optimize for it at this point given it's prevalence. If you know jQuery well, you can pick up any of the other frameworks easily enough.
 

3.3volts

Ars Praetorian
478
Subscriptor
I just ran across this article, and think that this is a great synopsis of the various schemas involved in modern JS frameworks. If you don't know what a promise is, or how to get started with async JS, I'd look at this document.

To pick up async, doing node for a weekend project really has influenced how I think in terms of blocking calls.
 
Status
Not open for further replies.