While gzip implementations are not familiar to me, there exist alternative compression methods that can be utilized.
An example of compressing a string using JavaScript with LZW encoding:
// LZW encode a string
function lzw_encode(input) {
var dictionary = {};
var data = (input + "").split("");
var output = [];
var currentChar;
var phrase = data[0];
var code = 256;
for (var i = 1; i < data.length; i++) {
currentChar = data[i];
if (dictionary[phrase + currentChar] != null) {
phrase += currentChar;
} else {
output.push(phrase.length > 1 ? dictionary[phrase] : phrase.charCodeAt(0));
dictionary[phrase + currentChar] = code;
code++;
phrase = currentChar;
}
}
output.push(phrase.length > 1 ? dictionary[phrase] : phrase.charCodeAt(0));
for (var j = 0; j < output.length; j++) {
output[j] = String.fromCharCode(output[j]);
}
return output.join("");
}