Removing MooTools

At this point you may think that this is not necessary, as the SC jQuery plugin loaded the jQuery library with the "no conflict" mode, and we had no problems between the libraries.

But at the moment we aren't using the MooTools library. So, why load it? Anyway, we are going to see a way of removing the MooTools library. There are lots of other ways out there. Later, you will be able to decide if you want to remove it or not.

So let's get started; we will do this in our template. Open the templates/jj15/index.php file. In the template we have the following code:

<jdoc:include type="head" />
                    <?php JHTML::_('behavior.mootools'), ?>
                

Replace this code with:

<?php
                    $headerstuff = $this->getHeadData();
                    unset($headerstuff['scripts']['/media/system/js/mootools.js']);
                    unset($headerstuff['scripts']['/media/system/js/caption.js']);
                    $this->setHeadData($headerstuff);
                    ?>
                    <jdoc:include type="head" />
                

What are we doing here? First we get all the header data:

$headerstuff = $this->getHeadData();
                

If we do this:

print_r($headerstuff)
                

In the code, we will see something similar to the following:

[scripts] => Array (
                    [/plugins/system/scjquery/js/jquery-1.3.2.min.js] => text/javascript
                    [/plugins/system/scjquery/js/jquery.no.conflict.js] => text/javascript
                    [/plugins/system/scjquery/js/jquery-ui-1.7.2.custom.min.js] => text/javascript
                    [/media/system/js/mootools.js] => text/javascript
                    [/media/system/js/caption.js] => text/javascript
                    [/plugins/content/ppgallery/res/jquery.prettyPhoto.js" charset="utf-8] => text/javascript )
                

These scripts were added to the header data in the extensions we have seen, using the following:

$document->addscript
                

By reading the header data, we are able to remove the scripts that we don't want without modifying the Joomla! Core:

unset($headerstuff['scripts']['/media/system/js/mootools.js']);
                    unset($headerstuff['scripts']['/media/system/js/caption.js']);
                

After we have done all of the necessary modifications we can set the header data and call it with the jdoc:include type="head" tag, as follows:

$this->setHeadData($headerstuff);
                    ?>
                    <jdoc:include type="head" />
                

And that's all. Now our site will load even faster. However, when we need MooTools we can easily turn it on again—quick and easy!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.163.250