Replace standart Joomla MooTools with yours on front-end

To keep upwards compatibility for your Joomla Core the following example shows a solution, by clearing the Header Buffer from the scripts Joomla is adding by itself. This is a template based modification, which does work with extensions loading their own Scripts or Stylesheets into the Header Buffer. And by that also transparent and not affected by any version upgrade to your Joomla Core:

<!-- Load MooTools by the template, and at the top before any other scripts -->
<?php
/* --- This removes any Joomla default Scripts from the Header Buffer --- */
$header = $this->getHeadData();                   // Get the current HEAD buffer
$header['scripts'] = array();                     // Clear all current 'scripts' entries
$this->setHeadData($header);                      // Update the HEAD buffer
/* --- We add the MooTools Framework manually, see below --- */
?>

<head>
<!-- Load MooTools at first -->
<script type="text/javascript" src="templates/<?php echo $this->template ?>/js/mootools/mootools-1.2.1-core.js"></script>
<script type="text/javascript" src="templates/<?php echo $this->template ?>/js/mootools/mootools-1.2-more.js"></script>
<script type="text/javascript" src="templates/<?php echo $this->template ?>/js/mootools/mootools-1.2-compat.js"></script>

<!-- Now all other scripts from extensions -->
<jdoc:include type="head" />

</head>


One Response to “Replace standart Joomla MooTools with yours on front-end”

  1. fragov says:

    I founded better way to remove base MooTools library, replace top < ?php ... ?> with:

    < ?php
    // no direct access
    defined('_JEXEC') or die('Restricted access');
    $template_baseurl = $this->baseurl . ‘/templates/’ . $this->template;
    $header = $this->getHeadData();
    unset ($header['scripts'][$this->baseurl . '/media/system/js/mootools.js']);
    $this->setHeadData($header);
    ?>

Leave a Reply