0

My website is using many javascript files of which some are loaded from the core. Is there any way to concatenate these js files into a single file? I've seen the usage of '|static'. But it is not wise to add '|static' into core file. So is there any way to achieve this in contao itself? I some other cms there is an option for "concatenateJS ". Like that, whether there is an option in contao core? If not, is there any other options for concatenation?

I had referred to https://rocksolidthemes.com/de/contao/blog/contao-ladezeit-optimieren. But it is not working?

5
  • What do you mean by "But it is not wise to add '|static' into core file"? Commented Dec 14, 2017 at 13:15
  • Usually we won't edit the core extensions. Because while upgrade, that changes will be lost.. Commented Dec 14, 2017 at 13:26
  • Which Contao version are you using? Commented Dec 14, 2017 at 13:28
  • Contao 4.3 is the version used. Commented Dec 14, 2017 at 13:29
  • You should update to Contao 4.4.8 btw. ;) Commented Dec 14, 2017 at 13:31

1 Answer 1

1

In Contao 4 you need to enable the Combine scripts option in your page layout. This will combine all scripts containing the |static flag into one file.

This options is enabled by default in Contao 4.5+

Sign up to request clarification or add additional context in comments.

2 Comments

I need to add a script tag just before the closing of the body tag. I wrote it as $GLOBALS['TL_JS_BODY'][] = '.../../js/script.js|static'; But it is not getting seen before the body tag. Is this is not the right method?
You can use TL_JQUERY, TL_MOOTOOLS or TL_BODY for that. I think it's preferable to use the latter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.