How do I prevent Joomla 4 from loading Bootstrap libraries in my template?

630 views
Skip to first unread message

Chris Bold

unread,
Apr 4, 2022, 11:16:54 AM4/4/22
to Joomla! General Development
I built a custom Joomla 4 template and unfortunately Joomla is automatically loading collapse.min.js in the head:

<script src="/media/vendor/bootstrap/js/collapse.min.js?5.1.3" type="module"></script>

This is conflicting with the curated Boostrap 5 files that my template already loads. The result that anything in my template that uses Bootstrap collapse (accordion, navbar) is broken.

How do I prevent Joomla from loading collapse.min.js (and bootstrap-es5.min.js, which is also being loaded) in my template? Any help appreciated!

Peter Tuson

unread,
Apr 12, 2022, 3:34:49 PM4/12/22
to Joomla! General Development
What template are you using?
I use cassiopea and cannot find an evidence of collapse.min.js being loaded. Also I have developed Joomla 4 plugins that use bootstrap modals, tabs and tooltips without problems.

I assume that you have looked at the json file and the index.php file within the template.

Regards,

Peter

Chris Bold

unread,
Apr 14, 2022, 9:22:25 AM4/14/22
to Joomla! General Development
Thanks Peter. I am using a template I built myself. I have another live site which uses this template, where this issue does not occur.

The template does not use a .json file, which is probably the issue.

This is my problem with developing Joomla 4 templates. Because I am a relative novice, and because the J4 template documentation is incomplete, my template development has been trial & error...

Best,
-Chris

Travis Risner

unread,
May 10, 2022, 9:47:10 AM5/10/22
to Joomla! General Development
While I haven't tried to do this on Joomla 4, on Joomla 3 I would do the following at the top of my template index.php file, and I believe it should work on Joomla 4. This should deal with any third party plugins or extensions that might be loading the javascript.

use \Joomla\CMS\Factory;
use \Joomla\CMS\Uri\Uri;

$doc = Factory::getDocument();
unset($doc->_scripts[Uri::root(true).'/media/vendor/bootstrap/js/collapse.min.js']);
Reply all
Reply to author
Forward
0 new messages