Skip to content

Commit 769e928

Browse files
bcordisclaude
andcommitted
perf: load core CSS/JS on demand instead of globally on front end
Move useStyle('cwmcore') and useScript('cwmcorejs') out of api.php for front-end requests. Views and modules already load these assets when needed via Cwmlisting::getFluidListing() and module Dispatchers. This eliminates render-blocking CSS (cwmcore.min.css, ~4KB) and unnecessary JS (cwmcorejs, ~8KB) from pages where Proclaim modules don't need them. Admin pages continue to load them globally. Lighthouse: estimated 150ms savings from unblocking initial render. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6ef1ea2 commit 769e928

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

admin/api.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,17 @@
9393
$language->load('mod_proclaim', $modProclaimPath, null, true);
9494
}
9595

96-
// Add to the API to load the component's core CSS and JS for proper functionality.
96+
// Register web asset registries so assets are available when views/modules request them.
97+
// Actual useStyle/useScript calls are made by individual views and module dispatchers.
9798
$wa = $app->getDocument()->getWebAssetManager();
98-
99-
// We register the extension registry because in modules and plugins, the registry is not automatically loaded
10099
$wa->getRegistry()->addExtensionRegistryFile('com_proclaim');
101-
$wa->useStyle('com_proclaim.cwmcore')
102-
->useScript('com_proclaim.cwmcorejs');
100+
101+
// Admin pages load core assets globally; front-end views load them on demand
102+
// to avoid render-blocking CSS/JS on pages that don't need them.
103+
if ($app->isClient('administrator')) {
104+
$wa->useStyle('com_proclaim.cwmcore')
105+
->useScript('com_proclaim.cwmcorejs');
106+
}
103107

104108
// Register lib_cwmscripture web assets (libraries aren't auto-discovered by Joomla)
105109
$wa->getRegistry()->addExtensionRegistryFile('lib_cwmscripture');

0 commit comments

Comments
 (0)