Is there maybe a better way to serve the adaptive images on initial page load via AJAX rather than setting the cookie and waiting for a page refresh? On initial page load, currently the original image size is being displayed for all images that use the adaptive image style. This may not be an issue when there aren't any images, with adaptive set as the image_style, on the front page or at the URL that the user is initially visiting, but when there are, you have to refresh the page for AIS to kick-in and swap the image.
Am I completely misunderstanding how the module is working? Is the fact that original images are being displayed by default, before a page refresh, a bug? Is it possible to "reload" the images, or their container, via AJAX?
-Erik
Demo Site that will replicate the issue: http://cndemo.dev4.webenabled.net
PS: make sure you clear browser cookies to see what I am talking about.
Comments
Comment #1
spotzero commentedYour understanding of what happens during the initial page load is correct. This behaviour is not a bug, it's just kind of the way this needs to work.
Think of adaptive images performance in the same way as caching performance. In the worst case scenerios, either Javascript is off, or it's the initial page load, or for whatever reason things fail and the AIS cookie doesn't get set, everything works normally, but you don't see and performance gain (like a cache miss). If the AIS cookie is set, then you get the performance boost.
Also, any solution to this problem needs to be a http://en.wikipedia.org/wiki/Progressive_enhancement, and if you AJAX load the images to ensure they're always adaptive, you're requiring decent amounts on JavaScript support to see images on your web site at all.
So far, I haven't seen a good way of providing adaptive images on the initial page load, but if you come cross one that meets the following requirement, I'll gladly implement it in this module.
1. Images and the site still load with JavaScript disabled
2. Renders in Internet Explorer
3. Runs faster on crappy devices than just loading the original sized images (low end phones may have trouble resizing images, but they tend to be better at images than they are at DOM traversals).