Skip to content

[Cookbook][Assetic] Update JS minifier recommendation #3247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cookbook/assetic/asset_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ To use a filter, you first need to specify it in the Assetic configuration.
Adding a filter here doesn't mean it's being used - it just means that it's
available to use (you'll use the filter below).

For example to use the JavaScript YUI Compressor the following config should
For example to use the UglifyJS JavaScript minifier the following config should
be added:

.. configuration-block::
Expand All @@ -248,25 +248,25 @@ be added:
# app/config/config.yml
assetic:
filters:
yui_js:
jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
uglifyjs2:
bin: /usr/local/bin/uglifyjs

.. code-block:: xml

<!-- app/config/config.xml -->
<assetic:config>
<assetic:filter
name="yui_js"
jar="%kernel.root_dir%/Resources/java/yuicompressor.jar" />
name="uglifyjs2"
bin="/usr/local/bin/uglifyjs" />
</assetic:config>

.. code-block:: php

// app/config/config.php
$container->loadFromExtension('assetic', array(
'filters' => array(
'yui_js' => array(
'jar' => '%kernel.root_dir%/Resources/java/yuicompressor.jar',
'uglifyjs2' => array(
'bin' => '/usr/local/bin/uglifyjs',
),
),
));
Expand All @@ -278,21 +278,21 @@ into your template:

.. code-block:: html+jinja

{% javascripts '@AcmeFooBundle/Resources/public/js/*' filter='yui_js' %}
{% javascripts '@AcmeFooBundle/Resources/public/js/*' filter='uglifyjs2' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}

.. code-block:: html+php

<?php foreach ($view['assetic']->javascripts(
array('@AcmeFooBundle/Resources/public/js/*'),
array('yui_js')
array('uglifyjs2')
) as $url): ?>
<script src="<?php echo $view->escape($url) ?>"></script>
<?php endforeach; ?>

A more detailed guide about configuring and using Assetic filters as well as
details of Assetic's debug mode can be found in :doc:`/cookbook/assetic/yuicompressor`.
details of Assetic's debug mode can be found in :doc:`/cookbook/assetic/uglifyjs`.

Controlling the URL used
------------------------
Expand Down