Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Google Closure Library offer over jQuery? [closed]

Considering

  • business background
  • community support
  • available extensions
  • default set of features
  • simplicity of use
  • and reliability

why do you prefer one over the another?

like image 943
pestaa Avatar asked Oct 02 '22 08:10

pestaa


People also ask

Why use Closure library?

If you are developing a large or growing application, you may benefit from the Closure Library's breadth. A well-tested library can insulate you from cross-browser compatibility issues and the minutiae of client-side programming, letting you focus on the fun stuff.

What is closure Google what is closure in JavaScript?

The Closure Compiler compiles JavaScript into compact, high-performance code. The compiler removes dead code and rewrites and minimizes what's left so that it downloads and runs quickly. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls.


2 Answers

I'll try to add my piece of information.

More than another JS lib

As I understand it, Google Closure is not only another JS library, but it is also a set of tools that will allow you to optimize your JS code. Working with jQuery gives you good tools and a lightweight library, but it does not minify your own code. The Closure compiler will. The closure inspector may also be useful, as sometimes minified code has a different behavior than the original one, and is a pain to debug. It integrates with Firebug and support unit tests, which are both developers' best friends nowadays.

Documentation

I guess that as any new library VS a well established one, it will lack the availability of tons of extensions and tutorial that jQuery has. However, being pushed by Google should ensure that support and reliability will be both pretty good. The current documentation and tutorial both seem really good, too.

Features

The features of Closure look decent, though, and its modular architecture is promising, too. I guess Google has been using it internally for a long time, which means that you could expect all basic features (and more) to be implemented, and probably in a very optimized and scalable way. They are trying to present it as the STL of JavaScript, so they should have polished it.

After looking at the features more closely, it seems that this may be a step forward for web-applications development compared to existing libraries as jQuery. It guess it benefits internal developments at Google, but things like detecting the online state (see goog.events.OnlineHandler), easy integration of AJAX requests and JS actions in the browser history (see goog.History), or the legions of great widgets they provide (see goog.ui package) may help all of us building even more awesome webapps ;) !

It comes with templates features that integrates with Java (who said GWT ?), so this may also be another plus for Closure.

Ease of use

Finally, it looks pretty simple to use. The syntax may be a bit more verbose than the short $ jQuery function, but with IDEs and auto-completion, it's not a real problem. Moreover, I'd say we can expect a good integration in IDEs like Eclipse, coming from Google.

EDIT: as requested, let me say a few words about the GWT reference. Google Web Toolkit is a Java library that allows to create AJAX-enabled web interfaces and that generates (and optimizes) the required JavaScript code. As Google Closure allows to create Templates that can be used both client- and server-side (using JavaScript and Java), my guess is that it will soon be possible to use them jointly (if it's not already the case).

like image 176
Wookai Avatar answered Oct 17 '22 05:10

Wookai


In my brief look at the API I find the differences between jQuery and Closure to be striking.

jQuery is basically just a simplified way to do many frequent operations in a cross-browser way.

Closure is a framework that is very new, in that they provide a cross-browser way to use the <canvas> tag, for example, and they have added new events.

So, this is adding onto what we typically do with javascript, they are taking many operations that people want to do and putting them into the API.

For example, they have an event to tell if the online state has changed. So you can tell if the system is online.

They have javascript functions that use tools such as Google Gears, which continues with the fact that they have extended what can be done with Javascript.

It will take me a couple of days to digest all the changes, but I can see that this could have a big impact on web applications that can be developed.

like image 30
James Black Avatar answered Oct 17 '22 04:10

James Black