PHP Joomla! 6 Joomla! 5 Joomla! 4 Template Basic

Load Bootstrap 5 JavaScript Modules On Demand via WebAssetManager

Enqueues only the specific Bootstrap 5 JS components needed (collapse, dropdown, modal, offcanvas) instead of the full bundle.

Updated on 24 November 2026 55 copies 187 views
templates/seu_template/index.php
<?php

declare(strict_types=1);

use Joomla\CMS\Factory;

$wa = Factory::getApplication()->getDocument()->getWebAssetManager();

// Carregue apenas os módulos realmente usados no layout
$wa->useScript('bootstrap.collapse')
    ->useScript('bootstrap.dropdown')
    ->useScript('bootstrap.modal');
Enqueues only individual ES modules rather than the monolithic bootstrap bundle.

Technical explanation and best practices

Joomla 5 and 6 ships individual Bootstrap 5 ES modules pre-registered in WebAssetManager. Loading only what your view uses keeps JavaScript payloads minimal for top Core Web Vitals scores.

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.