README.md
73 lines
| 1 | # JShrink [](https://github.com/tedious/JShrink/actions/workflows/pr_tests.yml](https://github.com/tedious/JShrink/actions/workflows/pr_tests.yml](https://github.com/tedious/JShrink/actions/workflows/pr_tests.yml) |
| 2 | |
| 3 | [](https://github.com/tedivm/JShrink/blob/master/LICENSE](https://github.com/tedivm/JShrink/blob/master/LICENSE](https://github.com/tedivm/JShrink/blob/master/LICENSE) |
| 4 | [](https://packagist.org/packages/tedivm/JShrink](https://packagist.org/packages/tedivm/JShrink](https://packagist.org/packages/tedivm/JShrink) |
| 5 | [](https://coveralls.io/r/tedivm/JShrink?branch=master](https://coveralls.io/r/tedivm/JShrink?branch=master](https://coveralls.io/r/tedivm/JShrink?branch=master) |
| 6 | [](https://packagist.org/packages/tedivm/JShrink](https://packagist.org/packages/tedivm/JShrink](https://packagist.org/packages/tedivm/JShrink) |
| 7 | |
| 8 | JShrink is a php class that minifies javascript so that it can be delivered to the client quicker. This code can be used |
| 9 | by any product looking to minify their javascript on the fly (although caching the results is suggested for performance |
| 10 | reasons). Unlike many other products this is not a port into php but a native application, resulting in better |
| 11 | performance. |
| 12 | |
| 13 | |
| 14 | ## Usage |
| 15 | |
| 16 | Minifying your code is simple call to a static function- |
| 17 | |
| 18 | ```php |
| 19 | <?php |
| 20 | include('vendor/autoload.php'); |
| 21 | |
| 22 | // Basic (default) usage. |
| 23 | $minifiedCode = \JShrink\Minifier::minify($js); |
| 24 | |
| 25 | // Disable YUI style comment preservation. |
| 26 | $minifiedCode = \JShrink\Minifier::minify($js, array('flaggedComments' => false)); |
| 27 | ``` |
| 28 | |
| 29 | |
| 30 | ## Results |
| 31 | |
| 32 | * Raw - 586,990 |
| 33 | * Gzip - 151,301 |
| 34 | * JShrink - 371,982 |
| 35 | * JShrink and Gzip - 93,507 |
| 36 | |
| 37 | |
| 38 | ## Installing |
| 39 | |
| 40 | ### Composer |
| 41 | |
| 42 | Installing JShrink can be done through a variety of methods, although Composer is |
| 43 | recommended. |
| 44 | |
| 45 | ```yaml |
| 46 | "require": { |
| 47 | "tedivm/jshrink": "~1.0" |
| 48 | } |
| 49 | ``` |
| 50 | |
| 51 | ### Github |
| 52 | |
| 53 | Releases of JShrink are available on [](https://github.com/tedious/JShrink/releasesGithub](https://github.com/tedious/JShrink/releases](https://github.com/tedious/JShrink/releases). |
| 54 | |
| 55 | |
| 56 | ## License |
| 57 | |
| 58 | JShrink is licensed under the BSD License. See the LICENSE file for details. |
| 59 | |
| 60 | In the spirit of open source, use of this library for evil is discouraged but not prohibited. |
| 61 | |
| 62 | |
| 63 | ## Reporting Security and Vulnerability Issues |
| 64 | |
| 65 | This project utilizes the [](https://tidelift.com/securityTidelift Security Reporting System](https://tidelift.com/security](https://tidelift.com/security) for security and vulnerability reporting. |
| 66 | |
| 67 | |
| 68 | ## Support |
| 69 | |
| 70 | Issues can be opened directly in Github for issues that aren't related to security. |
| 71 | |
| 72 | [](https://tidelift.com/subscription/pkg/packagist-tedivm-jshrink?utm_source=packagist-tedivm-jshrink&utm_medium=referral&utm_campaign=readmeProfessionally supported JShrink is now available with Tidelift.](https://tidelift.com/subscription/pkg/packagist-tedivm-jshrink?utm_source=packagist-tedivm-jshrink&utm_medium=referral&utm_campaign=readme](https://tidelift.com/subscription/pkg/packagist-tedivm-jshrink?utm_source=packagist-tedivm-jshrink&utm_medium=referral&utm_campaign=readme) |
| 73 |