What is an effective way to compress vCard data in a QR code using JavaScript? I tried the lz-string library, but I got an error when I tried to encode a QR code that I had illegal UTF-16 characters. Is there a better way?
If the vCard is intended to be read in open applications such as with general-purpose QR Code readers you can't simply compress the input data and expect the decoder to figure out how to decompress the resulting data.
One way of reducing the size of the resulting symbol is to ensure that the encoder makes optimal use of QR Code's numeric and alphanumeric encoding modes (rather than switching to the inefficient byte encoding mode) by restricting yourself to uppercase and numeric characters alongside basic formatting symbols if this is practical. You will however need to use a good QR Code generation library that determines the optimal switches between modes to minimise the internal data length in order to benefit from this technique.[*]
If you haven't already you should consider reducing the error correction level to "L".
Finally, consider using the more compact meCard format instead of vCard.
If the intended use is within a closed application (although I can't see this being the case for vCard) you could use GZIP compression (RFC 1952) and indicate this by prefixing the data with an ECI 001800 indicator. At scan time you can reliably determine the use of GZIP compression by placing a reader with ECI support into Extended Channel Mode to detect the presence of the ECI 001800 indicator and decompress accordingly within your application.
[*] Barcode Writer in Pure JavaScript is a JavaScript library that optimally encodes any given input to QR Code to provide the smallest symbol possible.