Adding custom js and css in a child template J5

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
pl71
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Tue Mar 18, 2014 11:24 am

Adding custom js and css in a child template J5

Post by pl71 » Tue Mar 26, 2024 7:11 am

So, what is the best approach to add some js and css files in a child template?
I'm trying with the 'joomla.asset.json' file.
But this file is located in the parent template folder (templates/cassiopeia), shall I have a local 'joomla.aset.json' file for my child template? When I created this child template, such a file didn't duplicate.
I want modifications to be specific for this child template only.
Is there a better approach? By better I mean fast in the first place, so I prefer writing some code, than installing extensions and plugins.

User avatar
pablop76
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Sat Dec 25, 2021 10:03 am
Location: Polska
Contact:

Re: Adding custom js and css in a child template J5

Post by pablop76 » Tue Mar 26, 2024 9:23 am

add the user.css file to the css folder and/or the user.js file to the js folder in the child template
https://docs.joomla.org/J4.x:Cassiopeia ... tomisation
Paweł
Company website: https://web-service.com.pl/
- Joomla passionate, Polska, Skierniewice

pl71
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Tue Mar 18, 2014 11:24 am

Re: Adding custom js and css in a child template J5

Post by pl71 » Tue Mar 26, 2024 11:00 am

Yes, this is obvious. Presently I have user.css and I added custom CSS code to the bottom of the file.
This is not so hard and you will end with only one CSS file for faster startup.
The downside is difficult to update - you have to locate custom code in user.css and replace it with a newer version if any.
So probably I will keep 2 CSS files, but the question is how to make that nicely and efficiently.


Post Reply

Return to “Joomla! 5.x Coding”