Scott Hanselman

Google Gears - Maybe all Rich Internet Applications needed was Local Storage and an Offline Mode

May 31, 2007 Comment on this post [26] Posted in Javascript | Musings | Tools | XML
Sponsored By

Stunning move by Google today in the Rich Internet Application space. While most of us (myself included) are off debating Flash vs. Silverlight vs. Apollo vs. Whatever, Google introduces Google technology all of the above (or none of the above) can utilize...

This is a huge move and is quite brilliant. In one seemingly innocuous move (and one tiny 700k (yes, 700K) download) Google is well positioned to get Google Docs, including Writely, Spreadsheet and Presentation, along with who knows what else, enabled for offline use. And the whole thing is Open Sourced via the New BSD License.

Here's a snippet of Javascript that is used to detect if Google Gears in installed. Note the three (currently) different ways, one each for Firefox, IE and Safari.

 var factory = null;

  // Firefox
  if (typeof GearsFactory != 'undefined') {
    factory = new GearsFactory();
  } else {
    // IE
    try {
      factory = new ActiveXObject('Gears.Factory');
    } catch (e) {
      // Safari
      if (navigator.mimeTypes["application/x-googlegears"]) {
        factory = document.createElement("object"); = "none";
        factory.width = 0;
        factory.height = 0;
        factory.type = "application/x-googlegears";

To the right is a dialog box that pops up to let you know that Google Gears is going to store data locally. Gears uses SQLite to store information, and you use SQL from your JavaScript to CRUD (Create, Read, Update, Delete) your data. I wonder how would would store data securely?

If you like, you can explore the databases that are created using SQLite Database Browser. This starts to explain why SQLite was a 2005 Google Open Source Award Winner. ;)

The local storage shows up when running Internet Explorer on Windows under:

Google\Google Gears for Internet Explorer\\http_80

Within Firefox, the local storage databases go in:

...\Application Data\Mozilla\Firefox\Profiles\
<profile>\Google Gears for Firefox

So it seems I can't go to a Gears-enabled site in IE and later in Firefox and share data. Each browser gets it's own data storage. That means num of browsers * num of gears enabled uris = num of SQLite databases. For folks who run more than one browser, this makes the whole local storage thing a tricky issue, but I can understand why they'd segment databases by browser. I disagree, but I see their point of view.

Gears also includes a thread pool "tiny process pool" like construct that lets you perform CPU-intensive things without triggering the "Stop unresponsive script" dialog box, but you can't touch the DOM. Again, very cool and very intelligent tradeoffs.

Things are looking up, methinks. It'd be nice if Gears-like (Gearsesque?) functionality could get built into next-gen browsers the way that XmlHttpRequest did. Seems like only yesterday I was deep in the middle of the Great Cookie Scare of 1995, explaining to client what Cookies were...NO, they can't write out a megabyte sized cookie, no cookies aren't programs...glad that's over. If we've going to build some rich stuff, let's stop with the Flash Shared Objects and IsolatedStorage already and get the browser to solve this problem. Kudos for Google and let's pray there's no offline ads...

Technorati Tags: , , , , ,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
May 31, 2007 10:09
When you combine this with Silverlight and .NET within the browser, the possibilities for the types of applications you'll be able to write are nearly endless.

Exciting times ahead...
May 31, 2007 10:28
Wonder how long it will be before Microsoft has a similar closed product that they will try to get everyone to install.
May 31, 2007 11:43
This is Google. Why wouldn't there be ads?
May 31, 2007 13:57
Ben: Microsoft have allready suggested that they will support offline storage in Silverlight. They have the security model in place, they have isolated storage, and they are soon shipping Sql Compact Edition (their answer to Sqlite).

So yes, they will support offline scenarios, and no, It's not to rip-off Gears...

But Gears is _really_ interesting. Totally agree with you Sam, the possibilities are endless. The only problem is that Silverlight supports Mac, and Win... Gears supports Win and Linux (no Mac yet). So the smallest common ground is Windows :P

But once Google get Mac support, and the Mono gys get Silverlight on Linux, you can really make some compelling stuff!
May 31, 2007 13:58
My bad, it works on the Mac! :)
May 31, 2007 17:15
Its definitely sounds like Google and I believe Microsoft is a few steps behind.
May 31, 2007 17:21
I downloaded the GoogleGearsSetup.exe but gave me an error.

I have xp. I know Google doesn't like MS but come on now. I can even test their stuff.
May 31, 2007 17:39
Flash Shared Objects == Isolated Storage == Google Gears local database.

They're all non-native(/standard) browser plugins.

Anyone know what's to stop me sitting in a loop (in the "thread pool" natch) inserting row after row after row into your local database?

Anyone fancy hosting a database on We could all share the same database!

May 31, 2007 19:36
I feel bad for adobe. now they are competing with microsoft AND google.
May 31, 2007 19:43

Interesting because last I looked they were promising Safari support but it wasn't ready yet.

Don't forget JavaDB
May 31, 2007 20:22
Cookies 2.0
May 31, 2007 21:02
Yes, Google Gears should work fine with Silverlight, just as it does with Flash Player. But Microsoft is working on its own database access layer for Silverlight, we're told. Will Microsoft do the right thing and support Google Gears in IE and Silverlight, or will their classic NIH force them to fork a parallel path? I suspect the latter, and its a shame.

Meanwhile, Apollo beta includes Google Gears. I'll bet you that Apollo will do as much to drive the technology to ubiquity as any single browser implementation (Firefox, Opera, etc.).
May 31, 2007 21:15
It'd be nice if Gears-like (Gearsesque?) functionality could get built into next-gen browsers the way that XmlHttpRequest did

Hear, hear! Although, you know what we'd get then... At least two (only two, if we're lucky) different implementations.

I've been getting into Javascript lately, and becoming increasingly frustrated that this very cool little language is plagued by so many variations between browsers. (Well, that and the "OO tax".)

Anyone know what's to stop me sitting in a loop (in the "thread pool" natch) inserting row after row after row into your local database?

That does sound like a danger. In my understanding, a savvy user could use the SQLite Database Browser to get rid of a garbage database.... But the question I suppose is whether/how they could be made aware that this had occurred at all.
May 31, 2007 22:16
Offline apps?

We've been doing this for years with IE and plain cache techniques. And if you create an HTA for IE, even better... you have full access to local file system, operating system calls, etc.

What is clear from all the brouhaha over Silverlight, Flash, Gears, etc, is that developers really want to create full applications with the ease of DHTML and Javascript.

See other attempts such as Dojo storage:

Web browsers and standards need to catch up to this, and yes provide standardized methods of storage, updates, etc.

May 31, 2007 23:46
Sounds like the Dojo Offline thing to me...
May 31, 2007 23:47
upp - sorry :
June 01, 2007 1:05
Web browsers and standards need to catch up to this, and yes provide standardized methods of storage, updates, etc.

Why? I'm sorry to sound MS-centric, but Silverlight provides this today (and with a much better programming model IMHO). .NET applications provide us with even more richness. Why does everything need to be in a web browser?
June 01, 2007 1:24
The main concept of Google gears is the local cache. But then the application has to be pure Javascript to work offline. Most of AJAX applications have a backend code Javascript connects to. How can that be made offline? I have a few more questions

June 01, 2007 3:30
And it's nice that the application (data and pages) can be cached locally, but what happens if the initial page drops out of the browser's cache? Your application is no longer available offline, right? There's nothing to bootstrap the whole experience...
June 01, 2007 3:53
Cookies 2.0?

Have you even looked at SQLite? You can stuff all sorts of things in the database and get it back out via SQL.

You can build a synchronizing n-tier web app on the desktop. If the thought of that doesn't make you drool, nothing will.
June 01, 2007 10:24
Why do you like the Gears approach over Isolated Storage? Because it fits more with the browser model?
June 01, 2007 19:05
There's one piece of the puzzle that you didn't talk about: Google Apps.

Google Apps can already automatically download applications as they are updated. All google needs to do is add these html "apps" to the list of apps available.

June 01, 2007 20:11
Lets not forget why the browser-based applications are important -- they represents the free, ubiquitous framework for accomplishing distributed work.

Hence, two things are necessary to lead to widespread adoption of browser plugins:
1) Ubiquitous client installation-base or fast, well publicized, zero-permission installs
2) Free (as in beer, with a splash of speech) application authoring

XMLHttpRequest passed both tests, by virtue of being integrated into the browser. Flash passed point 1, but failed at point 2, hence its not the defacto solution. Gears and Silverlight are iffy on point 1, so unless they're installable without administrative permissions (or easy pushed via SMS?!) their widespread within enterprise will likely be piecemeal.
June 02, 2007 9:38

"But once Google get Mac support, and the Mono gys get Silverlight on Linux, ..."

Apparently you don't realize that Miguel/Mono is becoming the most hated sellout of the entire software industry.

June 04, 2007 20:00
Spell check won't help you with "seams". I only mention it because of your recent focus on blog spelling being so key.
June 25, 2007 18:07
Hey Scott,

Check out the little google gears db query tool I implemented.

I'm finding it useful in developing client side db schemas for other gears enabled features I'm working on.


Joe Audette

ps, enjoying your podcasts

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.