PHPackages                             elephfront/robo-js-minify - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. elephfront/robo-js-minify

ActiveRobo-tasks[Utility &amp; Helpers](/categories/utility)

elephfront/robo-js-minify
=========================

Robo task to perform minification on your JS files.

1.0.0(8y ago)232.3k↓32.3%1MITPHPPHP &gt;=7.1.0

Since Jul 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/elephfront/robo-js-minify)[ Packagist](https://packagist.org/packages/elephfront/robo-js-minify)[ RSS](/packages/elephfront-robo-js-minify/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (1)

Robo JS Minify
==============

[](#robo-js-minify)

[![Software License](https://camo.githubusercontent.com/9a66612deb245a997157ce51e09a457827107c9cd9a9ee14c908c16fe9ee6f7f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f6272616e63683d6d6173746572)](LICENSE.txt)[![Build Status](https://camo.githubusercontent.com/0099fd8e37327a2480908751fa404e0c07941ad4db6064bb8936f043acfecad1/68747470733a2f2f7472617669732d63692e6f72672f656c65706866726f6e742f726f626f2d6a732d6d696e6966792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/elephfront/robo-js-minify)[![Codecov](https://camo.githubusercontent.com/04a495c5c6c93a8034433a65006913552da85a8cce8c88f60cf7681b155f662b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f656c65706866726f6e742f726f626f2d6a732d6d696e6966792e737667)](https://github.com/elephfront/robo-js-minify)

This [Robo](https://github.com/consolidation/robo) task performs a minification of your JS content.

This task performs the minification using [matthiasmullie/minify](https://github.com/matthiasmullie/minify) library.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.1.0
- Robo

Installation
------------

[](#installation)

You can install this Robo task using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require elephfront/robo-js-minify

```

Using the task
--------------

[](#using-the-task)

You can load the task in your RoboFile using the `LoadJsMinifyTasksTrait` trait:

```
use Elephfront\RoboJsMinify\Task\Loader\LoadJsMinifyTasksTrait;

class RoboFile extends Tasks
{

    use LoadJsMinifyTasksTrait;

    public function minifyJs()
    {
        $this
            ->taskJsMinify([
                'assets/js/main.js' => 'assets/min/js/main.min.js',
                'assets/js/home.js' => 'assets/min/js/home.min.js',
            ])
            ->run();
    }
}
```

The only argument the `taskJsMinify()` takes is an array (`$destinationsMap`) which maps the source files to the destination files : it will load the **assets/js/main.js**, do its magic and put the final content in **assets/min/js/main.min.js** and do the same for all of the other files.

GZIP compression
----------------

[](#gzip-compression)

In addition to minifying your files, you can gzip them. You can enable gzip using the `enableGzip()` method :

```
    $this
        ->taskJsMinify([
            'assets/js/main.js' => 'assets/min/js/main.min.js',
            'assets/js/home.js' => 'assets/min/js/home.min.js',
        ])
        ->enableGzip()
        ->run();
```

By default, files will be compressed using the maximum level (which is 9). You can customize the compression level using the method `setGzipLevel()` :

```
    $this
        ->taskJsMinify([
            'assets/js/main.js' => 'assets/min/js/main.min.js',
            'assets/js/home.js' => 'assets/min/js/home.min.js',
        ])
        ->enableGzip()
        ->setGzipLevel(5)
        ->run();
```

The `setGzipLevel` accepts values from `-1` to `9`. If you use `-1`, the default compression level of the zlib library will be used. `0` means you do not want any compression and `9` is the maximum level of compression. If you use a value that is out of these bounds, the maximum compression level will be used.

Chained State support
---------------------

[](#chained-state-support)

Robo includes a concept called the [Chained State](http://robo.li/collections/#chained-state) that allows tasks that need to work together to be executed in a sequence and pass the state of the execution of a task to the next one. For instance, if you are managing assets files, you will have a task that compile SCSS to CSS then another one that minify the results. The first task can pass the state of its work to the next one, without having to call both methods in a separate sequence.

The **robo-js-minify** task is compatible with this feature.

All you need to do is make the previous task return the content the **robo-js-minify** task should operate on using the `data` argument of a `Robo\Result::success()` or `Robo\Result::error()` call. The passed `data` should have the following format:

```
$data = [
    'path/to/source/file' => [
        'js' => '// Some JS code',
        'destination' => 'path/to/destination/file
    ]
];
```

In turn, when the **robo-js-minify** task is done, it will pass the results of its work to the next task following the same format.

Preventing the results from being written
-----------------------------------------

[](#preventing-the-results-from-being-written)

By default, the **robo-js-minify** task writes the result of its work into the destination file(s) passed in the `$destinationsMap` argument. If the **robo-js-minify** task is not the last one in the sequence, you can disable the file writing using the `disableWriteFile()` method. The files will be processed but the results will not be persisted and only passed to the response :

```
$this
    ->taskJsMinify([
        'assets/js/main.js' => 'assets/min/js/main.min.js',
        'assets/js/home.js' => 'assets/min/js/home.min.js',
    ])
        ->disableWriteFile()
    ->someOtherTask()
    ->run();
```

Contributing
------------

[](#contributing)

If you find a bug or would like to ask for a feature, please use the [GitHub issue tracker](https://github.com/Elephfront/robo-js-minify/issues). If you would like to submit a fix or a feature, please fork the repository and [submit a pull request](https://github.com/Elephfront/robo-js-minify/pulls).

### Coding standards

[](#coding-standards)

This repository follows the PSR-2 standard.

License
-------

[](#license)

Copyright (c) 2017, Yves Piquel and licensed under [The MIT License](http://opensource.org/licenses/mit-license.php). Please refer to the LICENSE.txt file.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3230d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7ade5318f46ea6ffa30a140639a71bb9f078f8322efc24268d0f94cd7c4deee?d=identicon)[HavokInspiration](/maintainers/HavokInspiration)

---

Top Contributors

[![HavokInspiration](https://avatars.githubusercontent.com/u/5243386?v=4)](https://github.com/HavokInspiration "HavokInspiration (11 commits)")

---

Tags

elephfrontjs-minifyroborobo-task

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elephfront-robo-js-minify/health.svg)

```
[![Health](https://phpackages.com/badges/elephfront-robo-js-minify/health.svg)](https://phpackages.com/packages/elephfront-robo-js-minify)
```

###  Alternatives

[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

38244.6k16](/packages/ec-europa-toolkit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
