Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Minify JS

Hi, new with PHALCON,

Trying to minify some js, code below:

public function fichaAction() {

  $this->assets
              ->addJs('./../js/jquery-1.11.2.js')
              ->addJs('../../js/jquery.validate.min.js')
              ->addJs('../../js/infodiv.js')
              ->addJs('../../js/jquery.imageZoom.js')
              ->addJs('../../js/JQueryValidationProductPage.js')
              ->addJs('../../js/popup-window.js')
              ->addJs('../../js/product2scjs')
              ->addJs('../../js/productpage.js')
              ->addJs('../../js/tabber.js')
              ->addFilter(new Phalcon\Assets\Filters\Jsmin());

I'm getting the error: * Call to undefined method Phalcon\Assets\Manager::addFilter()*

When I use without the addFilter(new Phalcon\Assets\Filters\Jsmin()), everything goes ok, but no minify, offcourse. All the examples use the addFilter, but when I look at the documentation, of the Phalcon\Assets\Manager there is no addFilter method.

Using PHALCON 1.3.4 on Windows

Thank you

You need to create a collection first.

$this->assets->collection('js')
->addJs('./../js/jquery-1.11.2.js')
->addJs('../../js/jquery.validate.min.js')
->addJs('../../js/infodiv.js')
->join(true)
->setTargetPath($pathToCompiled)
->setTargetUri($pathToCompiled)
->addFilter(new Phalcon\Assets\Filters\Jsmin());

//then in volt:
{{ assets.outputJs() }}


885

Look like it's working, now I have the error PhalconException: Non-free jsminifier not available ???

You need to create a collection first.

```php $this->assets->collection('js') ->addJs('./../js/jquery-1.11.2.js') ->addJs('../../js/jquery.validate.min.js') ->addJs('../../js/infodiv.js') ->join(true) ->setTargetPath($pathToCompiled) ->setTargetUri($pathToCompiled) ->addFilter(new Phalcon\Assets\Filters\Jsmin());

//then in volt: {{ assets.outputJs() }} ```



885
Accepted
answer

Thank you, that is the problem.

No another problem is tha I have the windows DLL, I have been reading and complie PHALCON in windows it is another level :)

Hi,

you have to recompile phalcon: http://forum.phalconphp.com/discussion/4212/minify-assets-error