Reputation: 26085
Due to a poorly configured CDN that I don't have control over, I can't access the accept-encoding
header from the server. Is it possible for client-side JS to determine which encoding schemes (gzip, br) are supported? Then, I can make requests like <script src="/script.js?encodings=gzip,br">
Upvotes: 2
Views: 139
Reputation: 26085
For now, I did:
var supportsBrotli = window.Symbol && Symbol.hasInstance && Symbol.toPrimitive && window.WebAssembly;
document.getElementById('script').src = '/js/script.js' + (supportsBrotli ? '.br' : '');
Those JS methods are from caniuse, it should work for Chrome, FF, and Safari.
Upvotes: 1