Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django, CloudFront, and respond.js

I'm trying to get media queries working in IE 8, and I've got Respond.js working nicely in development. However, when I deploy this to my production environment Respond.js isn't working it's magic. I've followed the instructions at GitHub for setting it up with a CDN (we use S3 & Cloudfront), and I've ensured that all the javascript and the respond-proxy.html file are available at the URL I've specified.

My current theory is that this is Django stopping Respond.js' AJAX somewhere along the way, in particular, evidenced by this line in my Django log:

WARNING Wed, 03 Oct 2012 15:22:13 +0000 base xxx xxxxxxx Not Found: /https://dxxxxxxxxxxxx.cloudfront.net/j/r/respond-proxy.html

It appears that it's trying to find /https://d... on the local server. The line appears several times per page request.

Here's the code:

<link rel="stylesheet" type="text/css" media="screen" href="https://dxxxxxxxxxx.cloudfront.net/static/css/style.css" />
<script type="text/javascript" src="/static/js/respond.src.js"></script>
<link href="https://dxxxxxxxxxx.cloudfront.net/static/js/respond-proxy.html" id="respond-proxy" rel="respond-proxy" />
<link href="/static/js/respond.proxy.gif" id="respond-redirect" rel="respond-redirect" />
<script type="text/javascript" src="/static/js/respond.proxy.js"></script>

Note that my CSS is compressed using django-compressor, as is my other JS. The above code is outside of the {% compress %} block.

like image 283
kevinharvey Avatar asked May 17 '26 03:05

kevinharvey


1 Answers

Turns out I needed to hack respond.proxy.js to get this to work. I commented out line 74 in checkBaseUrl():

//          href = bref + href;

Note that this could have been caused by other JS running on my page, and may not be (probably isn't?) a bug in respond.proxy.js.

like image 105
kevinharvey Avatar answered May 18 '26 21:05

kevinharvey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!