Skip to content

Does not load images hosted on Amazon S3, Cloudfront and other CDNs #40

avirambm opened this Issue Aug 11, 2012 · 13 comments

The library does not load images hosted on external servers, like Cloudfront.

Please advise, thanks.


@avirambm Yes, this is a technical limitation rather than a bug. The library checks if an image exists with an ajax request, which you can only do on the same domain. See issue #3.

In short, we check if the original image's URL is external and skip it to avoid errors. If you have any ideas for how to handle external (CDN, etc) images, please let me know.

ghost commented Aug 28, 2012

Does it load images that are on a subdomain of the domain. Like (images here) and (html here)


same problem with Amazon S3. I thought that was a caching problem. It will be great if it can with the normal image path find the retina one without using domain.


I just found the retinajs library, so am not familiar with its internals. But its currently not an option for me because we host all our static content on S3.

I was thinking that X-domain is only an issue for Ajax requests but not for image and scripts, so for external images, you could just attempt to load the @2x image via a javascript Image object, using onError and onLoad events on the object to determine whether there was a hit or not. If its a hit (i.e., the load event fires), you could then just set the src on the html img element to that of the Image object you just loaded. Thoughts? I'd be happy to branch and dig into the code if this idea sounds promising.


Would love to see external image support - that's the only thing preventing us from using this awesome script.


To re-ask caseyohara's question, would the script work if we make our CDN serve images from a subdomain?


The script should work for subdomains if the changes in this pull request are reverted and a proper document.domain value is set.

@mrlundis mrlundis added a commit to mrlundis/retinajs that referenced this issue Dec 21, 2012
@mrlundis mrlundis Allow subdomains in image paths, see issue imulus/retinajs#40.
Allows serving retina images from cname:d CDNs and S3 instances. The document.domain and/or CORS also needs to be set up.

Has anyone given @nebstrebor's idea a shot?

It seems like a better solution to check for image existence overall, avoiding all the issues with CORS for external sources and in theory reducing the amount of requests to one per image since the check would put the requested image in the browser cache.


Any news on this? I can't get retinajs to work with my Django/S3 server... and all my requests are done HTTPS as well...

wkoffel commented May 4, 2014

See Issue #149 for a request to explicitly add support for properly configured CORS domains.


Has there been any resolution on this? Having the same trouble.


@kieronkeenan There are several solutions available.

I patched the is_external check back in 2012 to accept any subdomain instead of only the current host name, which together with a relaxed document.domain setting (and CORS for S3) solves the problem if you're using a CNAMEd CDN. See mrlundis/retinajs@470383f for details.

Another options seems to be using the data-at2x attribute. See #66 and #124 for details on that.

@strues strues closed this Jun 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.