[5.8] Making the frontend lean by disabling C5-injected jQuery and CSS
Permalink
I've been struggling for a while now to remove the following lines from my header:
Documentation is a bit scarce these days about doing this in the 5.8+ world.
I'd like to include it in my header only if the user is a member of a certain group, say "Admininstrators".
<link href="/concrete/css/app.css" rel="stylesheet" type="text/css" media="all"> <link href="/concrete/css/account.css" rel="stylesheet" type="text/css" media="all"> <script type="text/javascript" src="/concrete/js/jquery.js"></script> <link href="/concrete/css/font-awesome.css" rel="stylesheet" type="text/css" media="all"> <link href="/concrete/css/jquery-ui.css" rel="stylesheet" type="text/css" media="all">
Documentation is a bit scarce these days about doing this in the 5.8+ world.
I'd like to include it in my header only if the user is a member of a certain group, say "Admininstrators".
Thanks, that's perfect. Concrete5 even handles on its own the cases where the toolbar is present and autoincludes jQuery so I can ignore the user logic.
It's all blazing-fast now. Just some reference for everyone who stumbles upon this.
BTW, I also had to re-activate my theme so C5 can find my page_theme.php.
It's all blazing-fast now. Just some reference for everyone who stumbles upon this.
BTW, I also had to re-activate my theme so C5 can find my page_theme.php.
<?php namespace Application\Theme\MyThemeFolderName; use Concrete\Core\Area\Layout\Preset\Provider\ThemeProviderInterface; class PageTheme extends \Concrete\Core\Page\Theme\Theme { public function registerAssets() { $this->providesAsset('css', 'font-awesome'); $this->providesAsset('css', 'jquery/ui'); $this->providesAsset('css', 'core/account'); $this->providesAsset('javascript', 'jquery'); $this->providesAsset('javascript', 'jquery/ui'); } }
If not logged in, it will say you provide these assets yourself, so it will not add them for you automatically. Bear in mind that jQuery stuff will be broken if you don't include jQuery yourself. So be sure to do that. I split the css/javascript, so you can see the difference.
You can open concrete/config/app.php to see which assets are all defined (under the 'assets' key of this file).