Problem/Motivation

If you don't want to output an image on for instance mobile phones, you now need to use display:none; to hide it, but there's still a request for the specified image.

Proposed resolution

The Drupal 7 version of the picture module has an option to map a breakpoint to an empty image. If you select this option the image source is replaced by 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'. So it adds like 50 bytes to the request, but it will not fire a new HTTP request.

Comments

This has the potential to have massive, huge, epic performance impact for Drupal on mobile devices. Many saved requests, kilobytes or even megabytes… means that this patch can potentially bring a site from loading in 20 seconds on a mobile device to 2 seconds. It depends on the site of course.

Increasing priority — even though that's likely to be contentious. This issue deserves more attention.

Back in March, I presented this base64 empty image idea to him and by the next day it was in 7.x-dev. Tested it and worked perfectly from the start. I'd be more than happy to test it on D8 if it gets patched in.

On mobile, there are times when certain images are just not necessary and using this method saves an http request as well as the image download. I've used this method in production and it does work as you'd imagine for increasing performance.

I'm sure the front-end geniuses will come up with an answer on whether or not there's a better way to handle this.

We should be using span elements, not picture elements. The picture element has not yet been standardized and implemented in browsers. It looks highly likely that will happen, but at this point we should be using a polyfill based on spans rather than picture elements. Otherwise if the picture element changes, then we have code written against the old version of the standard, which is bad.

As the issue linked in #5 explains, if picture is standardized and implemented prior to d8 launch, we can switch to the picture element. Otherwise that's a switch that could be considered for 8.1 or beyond.