From 3c4a108a4adcce5a591335cdbaae371a5abd4f9c Mon Sep 17 00:00:00 2001 From: Christoph Oberhofer Date: Sat, 14 Feb 2015 22:24:41 +0100 Subject: [PATCH] Updated README to include the correct handling of the uglify task --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd553f2..450f801 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ on desktop, nor on mobile. You can check [caniuse][caniuse_getusermedia] for upd In cases where real-time decoding is not needed, or the platform does not support `getUserMedia` QuaggaJS is also capable of decoding image-files using the File API or other URL sources. -## Installation +## Installation Just clone the repository and include `dist/quagga.js` in your project. You can also build the library yourself by simply typing: @@ -43,6 +43,29 @@ by simply typing: > grunt ``` +### Minification + +Currently, I strongly disapprove using `grunt uglify` since it does not handle asm.js code correctly +(see [issue](https://github.com/mishoo/UglifyJS2/issues/167)). The resulting code still works, but +the performance might suffer, especially in Firefox. Additionally it triggers some ugly log-warnings +in the console. + +This is how you create a minified version of quaggaJS (saved in `dist/quagga.min.js`): + +```console +> grunt uglify +``` + +Special care has to be taken if a minimized/uglified version of the code is needed. Basically the grunt task +`grunt uglify` takes the `dist/quagga.js` as input and saves the minified code in `dist/quagga.min.js`. +Since the introduction of web-workers in quaggaJS, the filename of the script is important, because +the instantiation of the workers rely on it. This script-name defaults to `quagga.js` and can be changed +in the config with the key `config.scriptName`. The supplied string must match the filename of the +file being served by the webserver. Now, in the case of a minified version, the config must be adapted +so that `config.scriptName` points to `quagga.min.js`. + +See the [config](#configobject) for all supported options. + ## Usage You can check out the [examples](http://serratus.github.io/quaggaJS/examples) to get an idea of how to use QuaggaJS. @@ -160,7 +183,7 @@ The callbacks passed into `onProcessed`, `onDetected` and `decodeSingle` receive } ``` -## Config +## Config The default `config` object is set as followed: