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">
Asked
Active
Viewed 80 times
2

Leo Jiang
- 24,497
- 49
- 154
- 284
1 Answers
1
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.

Leo Jiang
- 24,497
- 49
- 154
- 284