I would like to know if it is possible to compress via yui compressor in Symfony2 an inline javascript twig file.
the twig file contains js code as <script>/%JS code%/</script>
The doc states that it works for .js files but didn't mention the inline javascript
Asked
Active
Viewed 5,192 times
12

Aysennoussi
- 3,720
- 3
- 36
- 60
1 Answers
17
Allow me to tell you how I finally did it:
Install the bundle :
https://github.com/nibsirahsieu/SalvaJshrinkBundle
after that use the tag jshrink
<script type="text/javascript">{% jshrink %}
$(document).ready(function() {
// ...
});
{% endjshrink %}</script>
PS: if you're not using symfony you can download the library: https://github.com/tedivm/JShrink

Aysennoussi
- 3,720
- 3
- 36
- 60
-
Note that you can use this without Symfony via `$twig->addExtension(new \Salva\JshrinkBundle\Twig\Extension\JshrinkExtension)`. – mpen Dec 30 '14 at 23:12