Results 1 to 3 of 3

Thread: Loading and minifying JS

  1. #1
    User
    Join Date
    04-10-11.
    Posts
    162

    Default Loading and minifying JS

    Hi,

    i'm trying to find a way to minify all the JS for my site into one file. I've been using 3rd party tools to do this but I'd like to do this within Contao if possible.

    Contao already loads a minifyed script into the head:

    Code:
    <script src="assets/js/d7d683978e49.js"></script>
    Is it possible to add my custom scripts to this? I want to get to the point where only one js file is being loaded.

    I've tried loading the files through my localconfig.php using this:

    Code:
    $GLOBALS['TL_JAVASCRIPT'][] = 'custom-assets/js/custom.js';
    Contao just outputs this into the head as a standalone script, rather than adding it to the minifyed version. It would be much better if Contao could output everything in the $GLOBALS['TL_JAVASCRIPT'] into one minifyed script. Is there a way to do this?

    Thanks

  2. #2
    imported_Nina
    Gast

    Default Re: Loading and minifying JS

    Did you try and add the "static"-information?

    Code:
    $GLOBALS['TL_JAVASCRIPT'][] = 'javascript.js|static';

  3. #3
    User
    Join Date
    04-10-11.
    Posts
    162

    Default Re: Loading and minifying JS

    Thank you! I didn't know you could do that, that works exactly how I need it to.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •