Remove default js and css from required header
Permalink
Hi
Does anyone have a way of removing the follow from header required?
These are not needed on the front end, only when logged in and editing.
Thanks.
Does anyone have a way of removing the follow from header required?
These are not needed on the front end, only when logged in and editing.
<link rel="stylesheet" type="text/css" href="/concrete/css/ccm.base.css?v=f1269e5712d750bca90cfaed136f394a" /> <script type="text/javascript" src="/concrete/js/jquery.js?v=f1269e5712d750bca90cfaed136f394a"></script> <script type="text/javascript" src="/concrete/js/ccm.base.js?v=f1269e5712d750bca90cfaed136f394a"></script>
Thanks.
2. Find this:
$this->addHeaderItem($html->css('ccm.base.css'), 'CORE');
$this->addHeaderItem($html->javascript('jquery.js'), 'CORE');
$this->addHeaderItem($html->javascript('ccm.base.js', false, true), 'CORE');
3. Replace with:
if($u->isLoggedIn()) {
$this->addHeaderItem($html->css('ccm.base.css'), 'CORE');
$this->addHeaderItem($html->javascript('jquery.js'), 'CORE');
$this->addHeaderItem($html->javascript('ccm.base.js', false, true), 'CORE');
}
NOTE: If you're using jQuery in your theme, then make sure it's loaded BEFORE:
<?php Loader::element('header_required'); ?>
Otherwise it will conflict with the Concrete5 version and your edit mode won't work properly.
I find it's worth keeping Concrete's jQuery, rather than using a custom one as that way you always load the right one. The only reasons you'd have for using a different version is a) you prefer to use a CDN for jQuery to improve performance b) you're trying to use jQuery features/plugins which aren't in the jQuery version bundled with C5.
When you do need your own jQuery as well as Concretes it's advisable to put your jQuery in noConflict mode