imulus/retinajs — pull request #25 by Schnitzel (2012-07-06 11:47:16+00:00)
Title: Using asynchronous XMLHttpRequest for not blocking the browser

I'm using retina.js on http://www.osec.ch/de which is a pretty Image heavy page. The @2x Images are created on the fly with GD2, which can take sometimes quite long (500ms) because the images are big.

I encountered that on pages like the Startpage that during the HEAD XMLHttpRequests the whole Browser is stuck, no scrolling, no clicking, etc. Safari even shows the Beachball. After some research I found that you are actually using synchronous XMLHttpRequests which is the reason.

This change fixes this with using asynchronous XMLHttpRequest. I changed

has_2x_variant

to

check_2x_variant

with a callback function which gets true or false depending if the image has an 2x variant.

Also updated all tests.