2

I am using Cassiopeia and Joomla 4. I want to add a slideshow.js and user.css file.

I have already added the CSS file and it seems to be picking it up fine. I added the slideshow.js, but doesn't pick up automatically? How can I include this in the head?

Also, when I update Joomla will these files get wiped like they did with Joomla 3.x?

Note: I realise the CSS file appeared because I called it user.css, but with the slideshow file I need to load that after every other JS file.

1

1 Answer 1

3

The old method to add stylesheets and scripts to the doc head was to use the HTMLHelper. An good explanation how to use that: https://rolandd.com/blog/joomla/adding-stylesheets-scripts-and-images

Since Joomla 4 you can use Web Assets to add CSS/JS to your doc head, see: https://docs.joomla.org/J4.x:Web_Assets

More info about WebAssetManager and using it in Joomla 4 templates:

Never edit Joomla's core files. Core hacks can cause issues and can be overwritten with the next update. Instead you could use Template Overrides or Child Themes or add them using plugins.

More Tips & Tricks regarding Joomla's Cassiopeia template: https://magazine.joomla.org/all-issues/february-2022/joomla-4-cassiopeia-template-a-bunch-of-tips-tricks

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.