How do I stop Joomla from including jQuery?

I've recently upgraded from Joomla 3.2.1 to Joomla 3.2.2.

In Joomla 3.2.1, I manually unset jQuery from being included:

$doc = JFactory::getDocument();

$dontInclude = array(
'/media/jui/js/jquery.js',
'/media/jui/js/jquery.min.js',
'/media/jui/js/jquery-noconflict.js',
'/media/jui/js/jquery-migrate.js',
'/media/jui/js/jquery-migrate.min.js',
'/media/jui/js/bootstrap.js',
'/media/system/js/core-uncompressed.js',
'/media/system/js/tabs-state.js',
'/media/system/js/core.js',
'/media/system/js/mootools-core.js',
'/media/system/js/mootools-core-uncompressed.js',
);
foreach($doc->_scripts as $key => $script){
    if(in_array($key, $dontInclude)){
        unset($doc->_scripts[$key]);
    }
}

But this isn't working in Joomla 3.2.2. Is there a way to not include Joomla's jQuery in 3.2.2?

Another variation which works well for me with Joomla 3.4 is to edit the template > index.php file with something like:

$doc = JFactory::getDocument();

$headData = $doc->getHeadData();
$scripts = $headData['scripts'];

//scripts to remove, customise as required

unset($scripts[JUri::root(true) . '/media/system/js/mootools-core.js']);
unset($scripts[JUri::root(true) . '/media/system/js/mootools-more.js']);
unset($scripts[JUri::root(true) . '/media/system/js/core.js']);
unset($scripts[JUri::root(true) . '/media/system/js/modal.js']);
unset($scripts[JUri::root(true) . '/media/system/js/caption.js']);
unset($scripts[JUri::root(true) . '/media/jui/js/jquery.min.js']);
unset($scripts[JUri::root(true) . '/media/jui/js/jquery-noconflict.js']);
unset($scripts[JUri::root(true) . '/media/jui/js/bootstrap.min.js']);
unset($scripts[JUri::root(true) . '/media/jui/js/jquery-migrate.min.js']);

$headData['scripts'] = $scripts;
$doc->setHeadData($headData);

Hot to disable bootstrap, mootools, caption, jquery, How to disable bootstrap, mootools, caption and jquery scripts with no core hacks​? I am using latest J! 3. Unset is not working for jquery and  How do I stop Joomla from including jQuery? Ask Question Asked 5 years, 11 months ago. Is there a way to not include Joomla's jQuery in 3.2.2? joomla joomla3.0.

You need to add a prefix of JUri::root(true) before each of those file names - relative paths will not work

DD Disable jQuery, by HR-IT-Solutions GmbH, In the front end of Joomla jQuery ist loaded via the core including jQuery noconflict and jQuery migrate. With this plugin you can unset all these  Joomla 1.5/2.5 Mootools. Unless you are maintaining Javascript code which leverages Mootools or you are developing an extension for Joomla 2.5 or earlier it is recommended you use jQuery instead. Firstly, you will need to include the Mootools code in your extension. To include the Mootools framework in your extension,

I've added:

            $doNotInclude = array(
                'jquery',
                'bootstrap',
                'behavior',
            );
            if(in_array($file, $doNotInclude)){
                return;
            }

immediately after:

            list($key, $prefix, $file, $func) = static::extract($key); 

in libraries/cms/html/html.php, in the "_" function.

I don't like it since its a modification to the Joomla core but it works. I'm still looking for a better solution.

Stop Joomla! 3.4.1 from including scripts in custom component pages, '/media/jui/js/jquery-noconflict.js']);. Printing the contents of the $this->scripts array to the screen shows that it is empty on views generated  There are several ways to start using jQuery on your web site. Download the jQuery library from jQuery.com. There are two versions of jQuery available for downloading: Both versions can be downloaded from jQuery.com. The jQuery library is a single JavaScript file, and you reference it with the HTML <script> tag (notice that the <script> tag

You can also try something like this:

$removeScripts = [
    '/media/jui/js/jquery.min.js',
    '/media/jui/js/jquery-noconflict.js',
    '/media/jui/js/jquery-migrate.min.js',
    '/media/system/js/caption.js',
];
foreach ($removeScripts as $removeScript) {
    unset($this->_scripts[JURI::root(true).$removeScript]);
}

Disable script loading in head, In Joomla 3.x, you can call JHtml::_('jquery.framework') in your template to load jQuery without Mootools. This loads jQuery in no conflict mode by default so if  9. Save the plugin, clear your Joomla and browser's cache and reload your site. Add a jQuery script: Load it to your site from an External source: 1. Go to your Extensions -> Plugins -> System - eorisis: jQuery plugin in the Joomla Administrator and open the Add Files tab. 2.

The problem is with your in_array.

If you remove it by changing this:

foreach($doc->_scripts as $key => $script){
    if(in_array($key, $dontInclude)){
        unset($doc->_scripts[$key]);
    }
}

to this:

foreach($doc->_scripts as $key => $script){
    unset($doc->_scripts[$key]);
}

Then it works fine. It's pretty pointless checking if the array key exists as I gathered you haven't manually deleted any of these files yourself.

Hope this helps

Disable scripts loading in head section in Joomla!, It includes jQuery and jQuery-dependent scripts. We will be able to find out which scripts is loading in the templates with the “_scripts” array  jQuery and Joomla: This tutorial will show you how to use jQuery the most popular JavaScript library with your Joomla powered websites. jQuery in Joomla | How to use jQuery with Joomla Joomla Tutorials

Can you disable the load of native jquery from Joomla 3 · Issue , If you disable anything Joomla that requires jQuery, it won't load. Gantry itself is JS agnostic and only cares about running its own JS payload. jQuery es un framework recién introducido que integra Joomla! con el nuevo framework Bootstrap HTML; Mootools es el legado de la biblioteca Javascript de Joomla! que ahora es reemplazada por jQuery y se incluye por compatibilidad con extensiones de 3as partes.

How to fix Javascript conflicts in Joomla, Sometimes this can be easier said than done but the first thing you should try to do is to disable the setting Load jQuery from the  Avoiding Conflicts with Other Libraries The jQuery library and virtually all of its plugins are contained within the jQuery namespace. As a general rule, global objects are stored inside the jQuery namespace as well, so you shouldn't get a clash between jQuery and any other library (like prototype.js, MooTools, or YUI).

How to resolve jQuery conflicts in Joomla!, One common problem with Joomla! are numerous extensions that load or template feature has stopped working there may be a conflict with the jQuery 

Comments
  • Sorry I voted, a bit too early, this didn't work for me, on Joomla! 3.4.1 Stable.
  • If I dump the $doc->_scripts array, its empty. I think the issue is that Joomla changed how its including scritps
  • I've just checked my 3.2.2 and it IS populated. Where are you making this check? In a template or extension or what?
  • I'm making the check at the top of the template's index.php... it was populated there before I upgraded, I'm not sure why its not populated now
  • I have no clue. Try unzipping the update files again. Perhaps something went wrong in the upgrade. If the css files are being included though the script HAS to be populated at some point
  • Thaks a lot. This woks on my installation!
  • The problem is its not hitting that loop at all, since $doc->_scripts is an empty array
  • Try using JUri::root() . 'media/....' to define the paths. If this doesn't work, unless you have deleted the files manually, I'm not sure how it can be an empty string as I have just literally tested this myself on Joomla 3.3.2
  • I've dumped the $doc object and there is nothing in the scripts array.