XF 2.0 Minify JS ?

[F.A] Walky

Active member
Hello,

I'd like to know if this is possible to minify my JS files without using the xf-addon:build-release command. So I can easily add min="1" to my xf:js tag in template. Or is there another way to do this during the build-release ?

Best regards,
Walky
 
Last edited:
Is there a particular reason why the build release command isn't suitable?
I'd say yes.

When build-releasing, the JS is minified in a file : xxxx.min.js, but in template the code stills: <xf:js src="xxxx.min.js" />, this doesn't include the min="1", so the minified file is never used. Or maybe I'm missing something :rolleyes:
 
During development, you work with unminified files, so you'll have a file called xxxx.js and your JS tag would look like this:
Code:
<xf:js src="xxxx.js" min="1" />
To ensure we don't attempt to load the minified version during development (because it won't exist until the add-on is built), add the following to src/config.php:
PHP:
$config['development']['fullJs'] = true;
When you build the release, it will create the xxxx.min.js file. When a user installs the add-on, if they don't have the above config fullJs tag set to true then they will be loading xxxx.min.js automatically.
 
During development, you work with unminified files, so you'll have a file called xxxx.js and your JS tag would look like this:
Code:
<xf:js src="xxxx.js" min="1" />
To ensure we don't attempt to load the minified version during development (because it won't exist until the add-on is built), add the following to src/config.php:
PHP:
$config['development']['fullJs'] = true;
When you build the release, it will create the xxxx.min.js file. When a user installs the add-on, if they don't have the above config fullJs tag set to true then they will be loading xxxx.min.js automatically.
Thank you a lot ! :D
 
Back
Top Bottom