mootools.js and MobileJomla

Elimelech
4 years, 2 months ago
Can this code mootools.js be removed from the mobile site template?
https://meirbruk.net/media/system/js/mootools.js

I mean, so that it does not load when the mobile version of the site loads or is it needed?
dryabov
4 years, 2 months ago
As far as I remember, MooTools in Joomla 1.5 is usually loaded for two purposes:
1) generate tooltips for labels,
2) insert captions for images with class="caption" attribute.

In the preinstalled Mobile_Basic template (and additional premium templates) we use modified com_content layouts that don't load MooTools by default (until it is explicitly loaded by a plugin or component).
Elimelech
4 years, 2 months ago
So can MooTools Joomla 1.5 be disabled in the template? It is not needed for the normal operation of the mobile version of the site? I have a free version mobilejoomle
dryabov
4 years, 2 months ago
It's possible, but it's not so easy in 1.5. Joomla's com_content component loads MooTools via call to
JHTML::_('behavior.caption');
and Mobile extension overrides JHTMLBehavior class to do nothing for behavior.caption command. As a result, MooTools is loaded only if a plugin or a component explicitly executes behaviour.mootools command. So, if you have MooTools loaded in mobile version of your website, most likely it means it is directly requested by a 3rdparty plugin.
Elimelech
4 years, 2 months ago
$user = JFactory::getUser();
if ($user->get('guest') == 1 or $user->usertype == 'Registered') {
$headerstuff = $this->getHeadData();
$tmp = array();
foreach ($headerstuff['scripts'] as $path=>$type) {
if ( !preg_match('#media/system/js#i', $path, $ar) ) $tmp[$path] = $type;
}
$headerstuff['scripts'] = $tmp;
$this->setHeadData($headerstuff);
}
But what if I insert this code into the mobile website template?

or such:
<?php
$user =& JFactory::getUser();
if ($user->get('guest') == 1) {
$headerstuff = $this->getHeadData();
$key1 = JURI::base(true). '/media/system/js/mootools.js';
$key2 = JURI::base(true). '/media/system/js/caption.js';
unset($headerstuff['scripts'][$key1], $headerstuff['scripts'][$key2]);
$this->setHeadData($headerstuff);
}
?>
I want
so that mootools.js from Joomla does not load on the mobile version of the site
dryabov
4 years, 2 months ago
Just try. The latter code should be a little bit faster. If you use 3rdparty template, it should work. In the case of our Mobile_Basic and other premium templates, there is an option in its setting to do it automatically (but as far as I.can see, your desktop template is currently used in mobile version of your website).
Elimelech
4 years, 2 months ago
And what is the 3rdparty template?


Please look, have I inserted the code in the correct place in the template?

 <?php
/**
* Mobile Joomla! extension
* https://www.mobilejoomla.com
*
* @version 2.1.44
* @license GNU/GPL v2 - http://www.gnu.org/licenses/gpl-2.0.html
* @copyright (C) 2008-2019 Kuneri Ltd. / Denis Ryabov
* @date December 2019
*/

defined('_JEXEC') or die('Restricted access');
$user =& JFactory::getUser();
if ($user->get('guest') == 1 or $user->usertype == 'Registered') {
$headerstuff = $this->getHeadData();
$key1 = JURI::base(true). '/media/system/js/mootools.js';
$key2 = JURI::base(true). '/media/system/js/caption.js';
unset($headerstuff['scripts'][$key1], $headerstuff['scripts'][$key2]);
$this->setHeadData($headerstuff);
}
dryabov
4 years, 2 months ago
No, in the case of our mobile templates it's sufficient to just disable MooTools loading in the template's settings (see "Troubleshootings" section).

PS. Your code should work with any template, but note that files of Mobile_Basic template are overwritten every time you install an update to Mobile Joomla! extension, and so your changes in the template's index.php will be lost.

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.