How Instapaper works.

Marco Arment on how Instapaper works:

The bookmarklet has a mechanism to save pages from sites that require logins for full content, such as the Wall Street Journal and Harper’s, by sending a copy of the page’s HTML from the customer’s browser to the server. It’s like automating the “Save as…” menu item: if you have your own account for these sites and can see the page in your browser, you can save it to Instapaper.

The way it does this is ridiculous: instead of calling a simple GET request to save the page, since an entire page’s contents would quickly overrun any URL-length limits in the stack, it injects a FORM with a POST action and populates a hidden value with the page contents.

But form-data requests from browsers aren’t Gzip-compressed, so the resulting data is huge and needs to be sent over people’s (often slow, often mobile) upstream connections. So I found an open-source DEFLATE implementation in Javascript—really—and the bookmarklet compresses the page data right there in the browser before sending it.

The whole procedure is hideously complex, but works incredibly well.

I love it. That’s just the sort of hack-y stuff that I write but usually don’t admit. Maybe I should start writing about the weird code I cobble together to run my various sites.

If you’re not using Instapaper, you must. It justifies the existence of the iPad. It’s completely changed how I read long-form writing.

Published by Waldo Jaquith

Waldo Jaquith (JAKE-with) is an open government technologist who lives near Char­lottes­­ville, VA, USA. more »

5 replies on “How Instapaper works.”

  1. I have used Instapaper for a good two years now and love it. Have yet to really justify to myself the need for an iPad other than the cool factor.

    …come to think about it, I haven’t been able to justify the real book vs. the e-book either. Real books don’t have a battery life, are transportable, and look great on the wall.

    Eventually, this will be like talking myself into a cell phone in the mid-90s. Everyone else will have one, and once I get an iPad/eReader, I’ll wonder what the world was like.

  2. I bought it on Tuesday night after reading your recommendation, and it’s now my 2nd favorite iPad app (after Team Viewer). Thanks for the tip!

  3. Oooh, I’d never heard from Team Viewer. I’ve got to try that out.

    I can’t say enough good things about Instapaper. It does everything it should do and nothing it doesn’t need to. I just wish that Marco would provide some guidance for website developers, about how Instapaper scrapes text off of pages. That way those of us in the long-form-text world could optimize our websites to work well on Instapaper.

Comments are closed.