I feel that there should be a way to use the built-in browser functionality for un-gzip. If I am wrong, can someone explain why this browser function is not showing as javascript API?
No, it should not be if it is not a w3c standard, and it is not. The only standard that says something about gzip compression is the HTTP standard .
I really believe that it will not become standard, because there are thousands of algorithms (for compression, encryption, etc.) that you might want to use, and browsers cannot handle them; It would also be unfair to create interfaces for one algorithm without creating them for another.
The HTTP protocol is a kind of exception. Compression is done here to make life easier for millions of people. HTTP is the neck of the bottle in web performance, so while I have access to compression, I canβt imagine a single case where you need to use compression in JavaScript elsewhere. The only case I know is element compression in localStorage
/ indexedDB
, but even there gzip will not work because it does not produce UTF-16
output.
This is why it is not in the standard, and therefore it is most likely not to appear there.
Your specific case is a server-side implementation error. Using compressed output without the proper header really smells. Either do not use compression, or do it correctly.
And is there a way to un-gzip a file in javascript without adding an extra library?
In fact, in addition to this, there is a possible solution: create a browser extension that enters the correct header in the server response, and you do not need a library, but you will need to distribute the extension to users. It could be worse, but it can still work.
source share