How to update jQuery? Topic is solved

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
User avatar
JurajB
Joomla! Explorer
Joomla! Explorer
Posts: 474
Joined: Fri Oct 02, 2015 3:28 pm

How to update jQuery?

Post by JurajB » Wed Aug 05, 2020 1:38 pm

Hello, Im running bootstrap 4.5
wappalyzer says I have jQuery 1.12, in my template index.php I have cdn for jQuery 3.5.1 (latest).
How do I load new jQuery. Can you post here the script or solution before I start doing this by altering the files?
Thanks for advice.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 41255
Joined: Sat Apr 05, 2008 9:58 pm

Re: How to update jQuery?

Post by Webdongle » Wed Aug 05, 2020 3:00 pm

http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 23696
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: How to update jQuery?

Post by pe7er » Wed Aug 05, 2020 3:06 pm

You could unset jQuery in your template index.php and then load a newer jQuery.

In Joomla 3.8 and higher you could add the following name spaces at the top of your template's index.php

Code: Select all

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
Add some code to remove the unwanted jQuery scripts

Code: Select all

       $doc = Factory::getDocument();

        // Call JavaScript to be able to unset it correctly
        HTMLHelper::_('behavior.framework');
        HTMLHelper::_('bootstrap.framework');
        HTMLHelper::_('jquery.framework');
        HTMLHelper::_('bootstrap.tooltip');

        // Unset unwanted jQuery JavaScript
        unset($doc->_scripts[$doc->baseurl . '/media/jui/js/jquery.min.js']);
        unset($doc->_scripts[$doc->baseurl . '/media/jui/js/jquery-noconflict.js']);
        unset($doc->_scripts[$doc->baseurl . '/media/jui/js/jquery-migrate.min.js']);
Add some code to include the newer wanted jQuery scripts

Code: Select all

	// Load your own version of jQuery
        HTMLHelper::_('script', 'templates/your-template/js/your-newer-jquery.min.js', array('version' => 'auto'));
Maybe you might need to add the noconflict + migrate.min scripts as well like that
Kind Regards,
Peter Martin, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

User avatar
JurajB
Joomla! Explorer
Joomla! Explorer
Posts: 474
Joined: Fri Oct 02, 2015 3:28 pm

Re: How to update jQuery?

Post by JurajB » Wed Aug 05, 2020 5:20 pm

Webdongle has offered me solution I tested and works great, it has automated solutions, dont forget to set reporting to modal for admins in general options section so you can see the job done and solve conflicts
https://extensions.joomla.org/extension/jquery-easy/


Locked

Return to “General Questions/New to Joomla! 3.x”