4 ms·
On the topic of generating QR codes with JavaScript, I have a project that requires generating QR codes and the various libraries I could find all seemed to be
by daxterspeed 7y ago
On the topic of generating QR codes with JavaScript, I have a project that requires generating QR codes and the various libraries I could find all seemed to be rather... poor. A lot of them were simply made for another era of JavaScript, where the only way to generate the image was to set up a table, or even implement its own png encoder(?). There were a few more modern ones, with active development, but the changelogs weren't terrible re-assuring as they were mostly fixing bugs that really shouldn't happen in a standards compliant code generator.
In the end I settled on Project Nayuki's QR code library[0]. The JavaScript is targeting ECMAScript 5, but is commented really well so it's not too difficult to refactor it into ES6+. I'm hoping to publish my efforts soon, but it still needs some more work.
[0] https://www.nayuki.io/page/qr-code-generator-library https://www.nayuki.io/page/qr-code-generator-library
- fouc 7y agoAre you saying you don't like qifi's implementation?
- nayuki 7y agoThanks for the compliments! So actually, the ES5 targeting is my conscious choice for supporting Internet Explorer 11. Otherwise, you can see the use of the latest and greatest features in the TypeScript version: https://github.com/nayuki/QR-Code-generator/blob/master/typescript/qrcodegen.ts?ts=4 https://github.com/nayuki/QR-Code-generator/blob/master/type... I began this project in 2016 because I got disappointed by code quality when browsing online for C/C++ QR libs. The JavaScript versions were even worse, especially ones that ported C code poorly and verbosely. On my web page, the bottom section titled "Compared to competitors" contains a detailed commentary. On a related note, here you can learn about how QR Codes work at a low level: https://www.nayuki.io/page/creating-a-qr-code-step-by-step https://www.nayuki.io/page/creating-a-qr-code-step-by-step
- noir_lord 7y agoJust wanted to compliment you, this is a seriously impressive amount of work. I deal with QR codes at work (we use them for stock tracking) and the libraries previous Dev used aren't a patch on yours :).
- lioeters 7y ago> High-quality QR Code generator library in Java, JavaScript, Python, C++, C, Rust, TypeScript Excellent work! Really appreciate you open-sourcing this. In addition to its usefulness for QR code generation, having the same library in these different languages is educational for further study.
- qubyte 7y agoOne good thing about ES5 code is that it is ES6 code. ES6 is essentially a superset. Why refactor it when it works already and will always be more compatible as it is?
- shhsshs 7y agoqrcode on npm is pretty good. Very simple to use if you just need to convert a string to a QR code, and it has some advanced options if you want to get fancy. https://www.npmjs.com/package/qrcode https://www.npmjs.com/package/qrcode