First Look: Google Gears

The following is republished from the Tech Times #166.

As web applications have increasingly become go-anywhere repositories for the minutiae of our day-to-day lives (email, contacts, photos, appointments, to-do lists), there has been a behind-the-scenes race to make them keep working when you unplug your laptop from the Internet. Demos from Scrybe, Dojo, Zimbra, and others have promised great things, but it seems Google has come from behind to win the race with the launch of Google Gears.

As reported last week on the SitePoint Web Technology blog, Google has announced the beta release of Google Gears, a web browser extension that allows web applications to continue to work even when a user is disconnected from the Internet.

Gears works in Internet Explorer and Firefox on Windows, Mac OS X, and Linux, with a view to eventually supporting Safari as well.

Far from the plug-and-go solution that you might expect, Gears is actually just a layer of relatively low-level features that make offline web apps possible. A lot of the hard work is still up to you.

Gears gives you three features, which you access and control in your web application using JavaScript code:

  • LocalServer
    Register a collection of URLs that Gears will download and keep a local copy of for the user. The user’s browser will then transparently receive these local copies, which remain accessible when offline, instead of fetching the online versions. The local copies may be set to update automatically, or only when you want them to.
  • Database
    Store data in a relational database just like you would in your server-side code, except that your users each get their own database. You can also access this database more quickly from your JavaScript code, because the database is stored on the user’s computer. It also remains accessible to your LocalServer-cached JavaScript code when the user goes offline.
  • WorkerPool
    The least glamorous part of Gears, unless you’re a total JavaScript geek like me. Essentially makes JavaScript multithreaded, enabling you to run time-consuming operations (like parsing a large XML document, or downloading a bunch of data into a Google Gears database) in the background, without freezing the browser or causing script execution time warning dialog boxes to appear.

With these tools, you can build applications that not only keep working using local copies of HTML, CSS, JavaScript, and image files, but work faster because they can store user-specific data locally instead of having to retrieve it from the server all the time.

No doubt Google’s full range of online services will soon be enhanced with Gears-powered offline support. To begin with, however, Google has started with just one of these services: Google Reader. With Gears installed, you can now switch Reader into offline mode, at which point it will download up to 2,000 articles from your subscribed feeds for you to read offline. This manual switch works well enough, but it does rely on the user to remember to click it before going offline.

The main reason Google elected to launch Reader’s offline mode with a manual switch is because building offline applications isn’t easy. The freedom of having local copies introduces the burden of keeping them in sync with server-side resources (otherwise users will be unable to access their data from another computer, and you might as well just build a desktop application). This is a non-trivial problem, and one for which the most appropriate solution will change from project to project. the Gears Developer Site has a whole article on the issues involved.

No, Gears doesn’t make these things easy, but it does make them possible, and for now that may be innovation enough. No doubt the easy-to-use application frameworks built on these foundations are already on their way.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • Anonymous

    if i wanted offline content then i would use a desktop application, certainly not this contrived s****

    good for google to innovate in new technologies, and yes – let them flex their imagination by all means, but to try to go mainstrean with something that is niche is silly in my view.

    nah, this is just another one of those fads, much like web 2.0; what is next huh? web 2.1? when are we going to get web 2.2 huh? see where i’m going with this?

    a bemused dr livingston

  • malikyte

    Dr. Livingston, regardless of whether it seems useful in this specific example or not, we’ve yet to see how others can innovate with it. Ruby, as a language alone, wasn’t all that impressive. Why create yet another language when we already had so many, especially since Python was already so similar? Well, apparently the RoR team thought differently as they extended the use of the language to a level of cult following, and then enterprise adoption.

    It’s all about how it’s used, and why – and then how it’s extended beyond even what it was originally intended for. (Hopefully not for malicious acts, though I’m sure that’s on its way too.)

    Without innovation of some kind, where are we? I’m glad we innovate, whether the importance is noticeable right away or not. (Back in 1995, how many people saw the importance of CSS over tables?)

  • alimadzi

    I think this is a somewhat clunky first effort that will only appeal to ubergeeks (like me) for the time being. However I can see it becoming very pervasive as municipal wi-fi networks and mobile providers roll out more metropolitan wireless access. Soon we’ll probably be syncing websites and feeds in the background whenever we’re connected, browsing somewhat seamlessly using the cached content when we’re offline, and then resyncing when we connect again. I like the fact that Google is open sourcing the Gears code. I just hope the other big players get on-board like they have with the XML sitemap spec.

  • Anonymous

    cult following for ruby on rails may be, but enterprise level adaption is still some way off in my view; but back on topic i think i may have been too harsh.

    i am all for innovation, it’s human nature and what advances ourselves on a personal level, and in a science/technology level, and its not like we wont find a use for this technology; the demand for it is already here in fact but google gears its self, im not convinced…

    im sure they could have choosen a more apt database system for example? also what i ponder on is what about security? in an ever increasing networked world we need to be sure we know what we are getting ourselves into.

    dr livingston

  • malikyte

    All valid points. :) Time will tell. I like the idea of it as well, and perhaps it was pushed out all too soon (even if the Dojo team had been working on it for some time prior). As far as security concerns go — does it rest upon the developer (as in PHP), or in the framework language (as in .NET, well, more-so than PHP anyhow).

    (As far as enterprise adoption of RoR, I’d also agree, but since it’s one of the newer web-based framework “languages”, I thought it worked as a decent comparison.)