We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Compress inline js

How to write plugin/modifier to compress inline java script in volt. For example i have this in index.volt. I want to soft compress js, remove comments, uflify etc, so only to output:

<h1> Test header </h1>
<script type="text/javascript">
/* comments */
function abc(){
    alert('ok'); //comment
}
</script>

Volt is not made for that. Use Asset manager for that purpose.

Phalcon\Assets\Manager is available in the services container:

https://docs.phalcon.io/en/latest/assets