Over a million developers have joined DZone.

Simple Offline Application

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

I've written my fair share of single file applications. All the JavaScript and CSS are inline, and if I'm feeling particularly ninja, I'll base64 encode the images, and make them inline too.

To make the whole thing completely available offline is insanely easy, and reusable to boot.

The first step is to add the manifest attribute to the html element:

<html manifest="self.manifest">

In this case we've got a file called self.manifest which is pretty simple. It contains the following:


Yep, that's it. Since the application cache automatically includes the file that references the manifest file, we've now got an offline application cache for our single file app.

Make sure you're serving the manifest file correctly, if you're not sure, check out the HTML5 Doctor introduction to offline applications, but otherwise, that's it.

When I went away this last week, I wrote a little Boggle clone, and wanted it work offline on the plane - so I added this technique to the single file app (it's only the board and a countdown, not interactive).

Dirt simple, but totally reusable!

Note: the manifest file is subject to the same-origin rule, in that you can't point the manifest attribute to something like http://simpleapp.com/self.manifest. Equally, you can't base64 encode the manifest file as some people have asked in the comments - that would be really awesome!

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.


Published at DZone with permission of Remy Sharp, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}