February at paulcarvill.com, the home of Paul Carvill on the web 2010 at paulcarvill.com, the home of Paul Carvill on the web

link: paulcarvill at flickr

paulcarvill.com

Hi, I'm Paul Carvill and I'm a web developer. I am Head of Interface Development at LBi, Europe's largest digital agency.

I also like walking, cooking, Bollywood and rock 'n' roll.

Archive for February, 2010

links for 2010-02-18

Thursday, February 18th, 2010

links for 2010-02-17

Wednesday, February 17th, 2010

links for 2010-02-16

Tuesday, February 16th, 2010

links for 2010-02-15

Monday, February 15th, 2010

Mobile network operators are just big dumb pipes in the sky

Monday, February 15th, 2010

I think the idea of 24 of the world’s largest mobile phone operators coming together to ‘make it easier to sell and distribute mobile phone apps’ is laughable. This is what’s being announced today at a huge mobile trade show in Barcelona.

Apparently the mobile phone networks fear that at the moment they are in danger of becoming little more than “dumb pipes in the air”, with all the revenues created by applications going to software developers and the companies that operate the stores that supply them.

Well here’s news, mobile network operators — I would like NOTHING MORE than for you to be dumb pipes. Which shouldn’t be a problem because THAT’S WHAT YOU ARE! I want you to act in the same way I want all my other utilities — water, sewage, gas — to act. Like great, big literal dumb pipes. Subservient conduits. Enslaved vessels. I don’t ask British Gas to get together with all the other gas companies and brainstorm new hot dinner ideas I might want to try out. You know, using their GAS and all? No, I’ll rely on trained chefs, food writers and my vast collection of suspiciously cleanly-paged cookbooks for that. Specialists, in other words. Just you keep the gas coming, guys. In fact I’m not even sure British Gas are the people who supply my gas — THAT’S how little I care about my gas utility supplier.

Your problem, mobile network operators, is you think you’re better than that. You want us to love you. You want us to wonder what we’d do without you. But I mean, to continue the utilities analogy, it’s not like you even manufacture the porcelain toilet, or the brushed steel taps, that connect to the dumb pipes. Nope, you just take care of all that stuff sloshing about inside them, the stuff everyone takes for granted. I really don’t want Thames Water forming coalitions with other water companies to provide me with new and improved cocktail ideas, that I could make using, you know, the water they send to my house. No thanks, fellas, just keep the wet stuff coming, though, you’re doing a great job.

But the mobile operators don’t really care about their customers. They’re just worried about their profits, and how they’ll steadily lose them to every innovative company that encroaches into their tradtional space. Customers have literally zero loyalty to any of their carefully nurtured and obviously humanised brands. People are interested in technology and functionality, which are provided by the handset manufacturers and the software developers respectively. Those two groups are both also driven by profit, but, importantly, their mission is to deliver better technology and functionality than their rivals. Mobile operators, on the other hand, offer a binary proposition — you can either telephone, SMS or get on the web, or you can’t. Not a hard job, youd have thought.

Worse still, the mobile operators got themselves into this mess in the first place by offering their customers closed systems and restricted access; they attempted to own content and access to content through walled-garden web access. Their very offering relies on restriction and artificial handicapping, as they attempt to categorise and upsell customers into various arbitrary packages, the difference in whose actual cost is negligible. Mobile phone operators have a target figure they aim to extract from each customer every month. The actual makeup of the services and products they offer is virtually meaningless. So they have no one but themselves to blame when customers eagerly jump ship in favour of unlimited data access, real web access and a semblance of choice in what you do with your mobile.

Mobile phone operators have repeatedly show themselves to be unimaginative, exploitative, moneygrabbing corporate behemoths with no real understanding the mobile data world. I don’t see that changing any time soon.

links for 2010-02-14

Sunday, February 14th, 2010

In bed with CSSEmbed – using data URIs and mhtml to reduce HTTP requests

Friday, February 12th, 2010

My team at LBi have added a pimped version of CSSEmbed into the continuous integration process of the project we’re working on. CSSEmbed is a tool by Yahoo’s Nicholas Zakas which takes CSS files as input, searches them for usages of image URLs, locates each image file being used via its URL or filepath, converts it into base64-encoded data and embeds that data back into the stylesheet in the form of a data URI, replacing the original URL. This has the effect of reducing the number of HTTP requests your browser has to make to load all of the images a page requires — everything in the stylesheet is downloaded in a single request. Because the number of concurrent HTTP requests your browser can make is limited, using CSSEmbed increases the browser’s chances of downloading all assets as quickly as possible.

Image by jek in the box

Performance

In practice getting the best performance out of cssembed is something of a balancing act, and takes some trial and error to get right. The size of the CSS file bloats pretty quickly once you start embedding even relatively small images in it. My first attempt increased one CSS file from around 80KB to almost 900KB! Now, while this file only takes one HTTP request to fetch, it also blocks downloads in that request channel for the entirety of the time it takes to come down the wire. After some experimentation we found the sweet spot was to embed images that were less than 1k in size, as the increased CSS file size was in a much better ratio to the number of HTTP requests saved.

We’ve tested this using PNG, GIF and JPEG in Firefox, Safari, Chrome and IE versions 6, 7 and 8.

Comparison

Here’s a comparison of a page I picked at random from our current project, showing data for using data URIs, both with and without Gzipping of the transfers:

Page size (KB) Number of
HTTP requests
Avg cold cache download time (ms) Avg warm cache download time (ms)
Using data URIs 540 45 792.30 726.60
Using data URIs, gzipped 235 45 802.00 748.30
Using original css/images, gzipped 194 56 882.60 771.00
Using original css/images 483 56 849.00 773.60

That’s a 19% fewer HTTP requests. Pretty impressive!

Pimping CSSEmbed

With some great help from my fellow LBi-ers Andrew and Raul, we amended CSSEmbed to take more arguments than the standard version, including a maximum image size to convert to data, a .txt file listing the CSS files to convert, a file extension to append to the outputted files and a directory to output to.

Continuous integration

Here’s a quick list of the steps we took to automate our CSSEmbed process:

1. Create a manifest of the stylesheets you want to embed image data into
2. Add an ant target that executes the cssembed jar twice, once to create files containing datauris (for modern browsers) and then again to create mhtml files (for older version of IE). Supply argument lines as necessary. Our ant targets do the following:
a. Supply root URLs to be prepended to relative URLs in the stylesheet, so the cssembed jar can locate the image files
b. Specify output directories: /datauri and /mhtml, respectively
c. Specify a file extension for the mhtml files: mht
d. Specify the location of the manifest .txt file
3. Amend your page’s head to serve the appropriate stylesheets to each browser

Here’s one of our ant targets:

<java jar="tools/cssembed-0.3.5.jar" fork="true">
     <arg line="--root '${deploy.home}/${project}-build/'" />
     <arg line="-o '${deploy.home}/${project}-build/assets/css/mhtml'" />
     <arg line="--maxsize 1"/>
     <arg line="--mhtml --mhtmlroot http://${project}.build/assets/css/mhtml/" />
     <arg line="--outextension mht" />
     <arg line="'tools/css-manifest.txt'"/>
</java>

A brief word on mhtml

The reason we output the mhtml files with a different file extension and put them in their own directory is to work around some presentation bugs in IE7, specifically IE7 on Windows Vista. IE7 on Vista doesn’t seem to like parsing PNG files as mhtml data unless the data is hosted in a separate file and served up as Content-Type: text/plain. Putting the mhtml files in a seperate directory with the ir own file extension means our client can use Apache directives either to serve either files with that extension as plain/text, or to serve any files from a particular directory as plain/text. It gives them the option and adds no performance overhead at all.

Serving it all up

Finally, with some clever use of conditional comments, we can produce valid markup that will let each browser download just those files it needs to. Here’s how to do it:

* Stylesheets for all browsers go here
<link rel="stylesheet" href="/path/to/styles.css" />

<!--[if gt IE 7]>-->
 * The datauri stylesheets go here.
 * Modern browsers and IE > 7 will see them.
 *
 * Note that the opening tag of the
 * conditional comment above is fully
 * enclosed in an HTML comment.
 *
 * All IE browsers read the conditional
 * comment and act on it, so only IE 8
 * sees these links

<link rel="stylesheet" href="/datauri/styles.css />

 * Note again that the closing tag of the
 * conditional comment below is fully
 * enclosed in an HTML comment

<!--<![endif]-->

<!--[if lt IE 8]>
 * The mhtml stylesheets go here.
 *
 * Only IE < 8 will see them.
 *
 * This whole section is inside an HTML
 * comment, so only IE browsers read the
 * conditional comment and act on it.
 *
 * Only IE < 8 sees these links

<link rel="stylesheet" href="/mhtml/styles.mht" />

 * Note the closing HTML comment tag below.

<![endif]-->

<!--[if lt IE 7]>
 * Here's an example of another conditional
 * comment, for supplying IE 6 stylesheets
 *
 * This is nothing to do with cssembed, it's
 * just here for illustration

<link rel="stylesheet" href="/ie6styles.css" />

<![endif]-->

Now whenever our build script runs, our CSS files are checked for image URLs and new CSS files are created with image data embedded. At runtime each browser downloads the appropriate stylesheets using almost 20% fewer requests than before. This means the page is ready faster than it was before we used data URIs, and we've freed up bandwidth for other activity to take place.

links for 2010-02-11

Thursday, February 11th, 2010

links for 2010-02-10

Wednesday, February 10th, 2010

links for 2010-02-09

Tuesday, February 9th, 2010
  • Nick Bilton, editor of the NYTimes Bits blog, interviews data maniac Nicholas Felton, he of the Feltron Annual Report.

    "The works of Mr. Felton blur the line between art and data. They are a poetic haze of information and well-designed storytelling — and of course, the discipline to collect all this information each year. But they also signal the kind of data collection that is becoming easier for all of us to do."

  • Jonathan Zittrain writes on FT.com on Apple's closed system for the iPhone and iPad. "The Apple II was a clean slate, a device built – boldly – with no specific tasks in mind…Thirty years later Apple gave us the iPhone. It was easy to use, elegant and cool – and had lots of applications right out of the box. But the company quietly dropped a fundamental feature, one signalled by the dropping of “Computer” from Apple Computer’s name: the iPhone could not be programmed by outsiders"
  • I'm inexplicably excited by this guy's experiments with audio in the browser, having never really been interested in this area before and considered it pretty much a dead end:

    "I’m working with an ever growing group of web and Mozilla developers, along with some talented audiophiles, on a project to expose audio spectrum data to JavaScript from Firefox’s audio and video elements."