4 ms·
The main reason you should do this is not so much as a CDN fall-back, but to prevent users from downloading redundant files retrieved from other sites. Also re
by kmfrk 14y ago
The main reason you should do this is not so much as a CDN fall-back, but to prevent users from downloading redundant files retrieved from other sites.
Also remember to always use the https URL for the assets, whenever able.
- dmbass 14y agoIsn't using already cached assets one of the reasons to use a CDN for popular scripts?
- LocalPCGuy 14y agoExcept that the chance of the asset you are requesting being cached is pretty minimal. See https://github.com/h5bp/html5-boilerplate/pull/1327 https://github.com/h5bp/html5-boilerplate/pull/1327 for links and discussion about this. The conclusion seemed to be that is it likely that a CDN does provide some benefit, but more from a localization of content and offloading the bandwidth, rather than a speed or cache hit benefit.
- EwanToo 14y agoI might be missing something, but that link really only talks about the potential benefit of a file already being cached locally on the end-user's device. There's still a significant benefit in just storing the file closer to the end-user, rather than in a single central location, as the CDN is likely to have both lower latency and have higher bandwidth than the source website. Now, if your file was so unique and rarely accessed that it wouldn't even be cached on the CDN, then I'd agree with those findings.
- imjared 14y agoIs there a reason to use https over a protocol-relative url? My go-to is <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
- garfij 14y agoNo, protocol-relative is the way to go.
- sp332 14y agoI think HTTPS isn't a bad idea. You don't want some MITM messing with your 3rd-party JS.
- chrisbolt 14y agoIf you're loading your 3rd-party JS from an HTTP page, they already can.
- nicholaides 14y agoSure, but it's one less avenue for a MITM attack.
- pyre 14y agoSome older versions of IE don't like protocol-relative, IIRC. Depends on your target platform, and customer-base.
- Encosia 14y agoI've tested the protocol-relative URL in every version of IE that was available on Browsershots about a year ago (which went back even further than IE6, IIRC). None of them had trouble with it.
- pyre 14y agoI remember suggesting it to someone else at my previous employer and there were issues. It may have been Outlook[1] though. I can't recall off-hand. [1] http://stackoverflow.com/questions/4303633/preventing-secure-insecure-errors-by-using-protocol-relative-urls-for-image-sour http://stackoverflow.com/questions/4303633/preventing-secure...