Unset Joomla Scripts from Template (k2 and other)

Written by  Friday, 20 October 2017 19:19
// Unset unwanted Scripts - by name
$unset_scripts = array(
	'k2',
	'...',
);

foreach($this->_scripts as $name=>$script)
{
	if (!preg_match('#(' . implode('|', $unset_scripts) . '#i', $name))
	{
		continue;
	}

	unset($this->_scripts[$name]);
}

or if you use joomla v3.8.1 you can try this php code:

<?php
	$doc = JFactory::getDocument();
	unset($doc->_scripts[JURI::root(true) . '/media/system/js/mootools-more.js']);
	unset($doc->_scripts[JURI::root(true) . '/media/system/js/mootools-core.js']);
	unset($doc->_scripts[JURI::root(true) . '/media/system/js/core.js']);
	unset($doc->_scripts[JURI::root(true) . '/media/system/js/modal.js']);
	unset($doc->_scripts[JURI::root(true) . '/media/system/js/caption.js']);
	unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery.min.js']);
	unset($doc->_scripts[JURI::root(true) . '/media/jui/js/jquery-noconflict.js']);
	unset($doc->_scripts[JURI::root(true) . '/media/jui/js/bootstrap.min.js']);
?>

if you wand disable all js & css scripts - use code:

$doc->_scripts     = null;
$doc->_script      = null;
$doc->_styleSheets = null;

 

262 Read Last modified on Tuesday, 24 October 2017

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.

4 comments

  • Comment Link roblox lumber tycoon 2 cheat engine Saturday, 18 November 2017 22:12 roblox lumber tycoon 2 cheat engine

    I have interest in this, thanks.

  • Comment Link Hugh Wrenne Friday, 24 November 2017 12:38 Hugh Wrenne

    I conceive you have mentioned some very interesting details , appreciate it for the post.

  • Comment Link fetch tv box hack Mac OS Sunday, 03 December 2017 15:06 fetch tv box hack Mac OS

    Thank You for this.

  • Comment Link 2018goup Sunday, 04 February 2018 04:36 2018goup

    I am also writing to make you understand what a really good encounter my daughter gained checking your webblog. She picked up a good number of things, with the inclusion of what it is like to have an excellent coaching style to get the others clearly learn various impossible topics. You really surpassed our own expectations. I appreciate you for distributing such powerful, safe, edifying and easy thoughts on your topic to Tanya.

Related items

  • [solved] Deprecated: Methods with the same name as their class will not be constructors ... www/plugins/content/jw_sigpro/jw_sigpro.php on line 19

    If you update your hosting to v7.1 & more - you can look same notification 'Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; plgContentJw_sigpro has a deprecated constructor in .../www/plugins/content/jw_sigpro/jw_sigpro.php on line 19'

    This code fix this problem you need Open plugins/content/jw_sigpro/jw_sigpro.php find this code in line 28:

    function plgContentJw_sigpro(&$subject, $params)
    	{
    		parent::__construct($subject, $params);
    
    		// Define the DS constant under Joomla! 3.0
    		if (!defined('DS'))
    		{
    			define('DS', DIRECTORY_SEPARATOR);
    		}
    	}

     And replase it to this code:

    public function __construct(&$subject, $params) {
    	parent::__construct($subject, $params);
    
    	// Define the DS constant under Joomla! 3.8.2+
    	if (!defined('DS')){
    		define('DS', DIRECTORY_SEPARATOR);
    	}
    }

    Awesome - it work done! :-)

    If you see same problem with jw_sig.php  - just download free new plugin from GitHub and install it: https://github.com/joomlaworks/simple-image-gallery

  • 7 tips to improve Joomla website performance [part 2]

    To continue with the tips to improve Joomla website performance, in the previous part, I had introduced how to use caching and .htaccess Optimization Rules, in this part, I will show you some other tips and hope you find it useful.

    Joomla Compression

    This is also an effective feature to optimize your website performance. When you enable this feature, the web page will be compressed and of course, the compressed page will take less time to load. Here is the way to enable Joomla Compression:

  • 7 tips to improve Joomla website performance [part 1]

    If you want to check the speed of your Joomla website, let’s start with speed test first. It can be said that site speed is one of the most important factors that affect directly a site performance. All your effort put into user-friendly interface, conversion rate optimization, high-quality content, and other things will not make sense if your page takes visitors too much time for loading.

    Of course, I do not deny that Joomla is one of the most powerful CMS and the best choice for any business owners who want to have websites easily but it had better improve your site speed continuously. You can increase the speed of your Joomla site by using its inbuilt features and follow the tips I will mention in this article.

  • Joomla! 4 – The hope of promising year 2018

    During 2017, we have heard a lot of opinions that this year has been too gloomy for Joomla. However, we think that this year is so important because it is the stepping stone for the explosion in 2018 when we prepare to welcome Joomla! 4.0 and Joomla! Framework 2.0. In addition to introducing several new features, including a fully rebuilt Media Manager, an enhanced event dispatching system, and new security features such as support for prepared SQL statements, we have also been doing some routine maintenance and paying off some of our project’s technical debt by retiring deprecated code and raising the minimum supported software stack. And, with this released version, we also require PHP 7.

  • [solved] How to disable unneeded scripts in joomla 3.6 (img.caption js.migrate...)

    joomla 3.6.4 default template c215a

    To disable scripts you can insert here the php code in the head pattern

    <?php
    unset($this->_scripts[$this->baseurl.'/media/system/js/mootools-core.js'], 
    	$this->_scripts[$this->baseurl.'/media/system/js/mootools-more.js'],
    	$this->_scripts[$this->baseurl.'/media/system/js/core.js'],
    	$this->_scripts[$this->baseurl.'/media/jui/js/bootstrap.min.js'],
    	$this->_scripts[$this->baseurl.'/media/jui/js/jquery.min.js'],
    	$this->_scripts[$this->baseurl.'/media/jui/js/jquery-noconflict.js'],
    	$this->_scripts[$this->baseurl.'/media/jui/js/jquery-migrate.min.js'],
    	$this->_scripts[$this->baseurl.'/media/system/js/caption.js']);
    
    if( isset($this->_script['text/javascript']) ) {
            $this->_script['text/javascript'] = preg_replace('\.addEvent\(\'load\',\s*(\'img.caption\'\);\s*}\);\s*%', '', $this->_script['text/javascript']);
            if( empty($this->_script['text/javascript']) )
            unset( $this->_script['text/javascript'] );
    };
    ?>