Thursday, October 13th, 2005

Benchmarking XHR vs. IFRAME, and a Neat Hack

Category: Ajax

Now that so many toolkits abstract away the transport used to make Ajaxian requests, one might wonder whether it matters if XHR or a hidden IFRAME is used to communicate with a server.

Emil Eklund tackled that question way back in April:

More then anything XML HTTP has enabled developers to make background HTTP requests a lot easier, and a lot faster. It does, however, raise a whole lot of questions; How much faster? Is it always faster? How about caching?

His conclusion?

This clearly demonstrates that XML HTTP is a lot faster than using a hidden iframe for small requests, most likely due to less overhead. As the filesize is increased the advantage obviously shrinks, as the majority of the time is spent transferring the data instead of handling the request.

He also has some material that’s a bit redundant with our previous entry on the subject of script caching.

On a side note, many years ago I thought I was cool because I had hacked up a way for people to see what MP3 I was listening to when they visited my website using a cheezy Perl script. Erik takes that concept way further on his own website:


The progress bar moves in real-time, which creates an interesting effect. Of course, it’s a fake-out; he transfers the length of the song and then increments the progress bar entirely on the client, but it’s neat none-the-less. And of course, Perl on the back-end. ;-)

Posted by Ben Galbraith at 10:09 am

3.4 rating from 7 votes


Comments feed

I guess you forgot the link ;) here it is:

Comment by Alexander Kirk — October 13, 2005

Never was much good at proof-reading… ;-) Thanks Alexander.

Comment by Ben Galbraith — October 13, 2005

One place where I still find iframes useful, is where I want to load up some HTML content on the fly and it may or may not actually be valid XML and getting it valid is out of my hands. In this case, an iframe is great for leveraging the browser’s parsing machinery to get access to a DOM in the iframe.

Comment by l.m.orchard — October 13, 2005

Leave a comment

You must be logged in to post a comment.