My JavaScript book is out! Don't miss the opportunity to upgrade your beginner or average dev skills.

Tuesday, May 29, 2012

on "manifestcontentavailable" event

Even native apps have something like a preload when it comes to launch them ... and guess what happens during that time?
Nothing that different from synchronizing content or looking for an update, isn't it?

Same Could Be For Mobile Web Apps
If you need your manifest to be loaded, in order to provide best UX ever, you might need a mechanism to be sure that everything that has to be there ... oh well, is simply there!

AppCache VS Binary
Well, one handy thing about the Application Cache Manifest for Web Apps is that you might update only a single part of your software.
As example, if you have external libraries you might decide to serve them a part, as external or independent content from the rest of the app ... and rather than download again the whole thing, the user will update only that dependency ... I mean, this is cool but rarely used due common build processes where a single changed comma of a single file will require the whole app file update, you know what I mean?

My "manifestcontentavailable" event proposal
Nothing really skilly here, simply a handy event that could be useful for any sort of app that would like to have everything available ASAP ... where everything is actually any file in the home page plus any file present in the manifest.
Conditions considered in this proposal are:
  1. the manifest has been fully downloaded, first visit in your page
  2. the manifest changed somewhere, new files have been replaced locally
  3. the manifest didn't change at all, everything is already available
  4. the user is offline, no need to even bother with new manifests or files
All other cases where the manifest is corrupted ... well, aren't a matter of this event since we all have tools to be sure that the manifest points ti existent files and everything is OK, right?

This is basically it ... a loading spinner in charge of entertainment for new users and those waiting to update their content, a basically instantly available page once users are offline.
The main point is: users download the whole thing once connected and, theoretically, never again thanks to the manifest mechanism.
The page itself doesn't do much more than show a spinner while the real stuff is being downloaded.
Once this content is available, and except for those JSONP calls to our favorite online service, the experience should be as smooth as possible without hundreds of spinners in the wild during our Web Ap interaction ... and I believe this is cool!
The script, easily minifyable in a bounce of bytes, should do the trick with all modern/mobile browsers and in a totally unobtrusive way ... if you listen to that event, you get it, otherwise nothing else will change.

I believe we are not getting the full power of this manifest concept so far and a proper event able to notify what's going on there, easy to setup, use, and configure, could be a must have for many Web Apps out there but please feel free to comment here what'ya think about this approach, side effects, or problems I might have not considered, thanks!

No comments: