AdLib: Apple's Secret Weapon For Making Better Web Apps For The iPad

Did you give in and buy yourself an iPad? Go grab it. If you don’t own one, just reach your arms out, conjure up a temporary air of smugness, and play along.

Now take your iPad (or your imaginaryPad, or what have you) and pop into Safari. Hit the bookmarks button, and then tap “iPad User Guide”. Explore a bit. Notice the dual-pane view with independent scrolling; notice the elasticity of the views. Notice that, outside of the URL bar up at the top, it looks and feels just like a native application.

Half of the hacky-type people reading this article have probably already bailed to go tear apart the source code at this point. Why? Because Web Apps don’t really work like this; HTML, CSS, and the standard javascript libraries really just don’t provide any of this functionality. It looks like Apple has something up their sleeves to make iPad Web Apps a bit more.. app-like.

It’s always been one of the primary complaints about Web Apps: no matter how much time developers dump into them, they just can’t make them feel like the stuff that comes out of the App Store. Maybe the tool bar would float out of view, or clicks just wouldn’t register naturally, or scrolling would seem “off”. It would take hours of scripting work just to get something that mostly emulated the feel of a basic native application.

Back in December of last year, John Gruber noticed that the on-handset iPhone user guide exhibited a bunch of behaviors that web apps normally couldn’t. Tool bars locked in place, clicks felt natural, and scrolling elements seem to emulate those found in native apps. He did a bit of tinkering, discovering that this was all made possible by a custom Javascript framework built by Apple called “PastryKit”. This iPad sorcery appears to be an extension of that.

The guys who brought it to our attention, Done21, are tentatively referring to this unannounced, not-quite-public framework as “AdLib”, after the file that contained it all: AdLib-ug-ipad.js. This name is by no means official – it’s just the best thing we’ve got, so far.

Coming in at just shy of 4,500 lines of code, the entire purpose of AdLib appears to be to bring native app-esque functionality to Web Apps, often counteracting the default behaviors that make Safari play nice with the rest of the web.

Alas, it’s entirely unclear if Apple ever plans to make this available to developers for their own use. Given the transparent nature of Javascript, it’s entirely possible that developers could just rip the framework from Apple’s guide and start stabbing away — but they’d be doing it without documentation of any sort. Working with someone else’s code without documentation — especially code that’s been optimized down to the bare minimums, as this has — is a bit like manning a plane’s cockpit sans instruction.