Chapter 14. Packaging Apps as Bookmarks: Bookmarklets and Data URLs

Because iPhone Web applications function inside the Safari environment, as a Web developer, you have two seemingly obvious restrictions: you must live with the built-in capabilities of the Safari/WebKit browser; and you need a constant Wi-Fi (or, for iPhone, 3G) connection to run any application.

As you already found out in Chapter 13, "Bandwidth and Performance Optimizations," you can use HTML5 offline storage capabilities to get around the dependency on a live connection. However, two lesser-known technologies — bookmarklets and data URLs — can provide similar results. These technologies have actually been around for years, but they have tended to exist on the periphery of mainstream Web development. However, developers are now reexamining these two developer tools to maximize the potential of the iPhone Web application platform.

Bookmarklets (short for bookmark applets) are mini JavaScript "applets" that can be stored as bookmarks inside Safari. A data URL is a technique for storing an entire Web page or application (pages, styles, images, data, and scripts) inside a single URL, which can then be saved as an iPhone bookmark inside Safari. This application-in-a-bookmark can then be accessed in offline mode.

Bookmarklets

A bookmarklet is JavaScript stored as a URL and saved as a bookmark in the browser. It is typically used as a one-click applet that performs a specific task or performs an action on the current Web ...

Get Safari® and WebKit Development for iPhone® OS 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.