The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 16 posts ] 
Author Message
PostPosted: Sun Mar 11, 2012 3:44 pm 
Joomla! Intern
Joomla! Intern

Joined: Thu Sep 27, 2007 1:24 am
Posts: 62
I'm working on some fairly simple joomla 2.5 websites. With little content the page weight should be small and page load speed fast. Not so though. Even used the core default templates I see the site loading some extraneous files such as mootools-more.js.

It appears that mootools-more.js is required for administration, but not with the public site. Can someone point me to how to disable it (and possibly other unnecessary) javascript (even jquery) files for public but not mess up administration?

Perhaps set up an if/else test and if the user is on the public site it does not read these heavy files? Maybe change the function that loads administration vs public so that admin gets the file whereas public bypasses.

I'm sure this would greatly improve page load speed.


Top
 Profile  
 
PostPosted: Sun Mar 11, 2012 5:38 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Thu May 27, 2010 1:00 pm
Posts: 688
You can do a code hacking by adding one line inside your template. Locate index.php file from the template folder, and inside this file right before starting the html code, in the php code area, you can add the following line:

unset (JFactory::getDocument()->_scripts['/media/system/js/mootools-more.js']);

If you have joomla installed into a folder, not into the root, like for example http://mywebsite.com/myjoomlainstall/ you must alter the code provided before and add the folder :

unset (JFactory::getDocument()->_scripts['/myjoomlainstall/media/system/js/mootools-more.js']);

This should do the trick.

_________________
Ionut Lupu - developer @ http://beesto.com
if [ you are interested in: Client Area, Restaurant Booking, Affiliate, HelpDesk, File Download ] ; then
it might be worth checking our Joomla Extensions: http://beesto.com/index.php/extensions


Top
 Profile  
 
PostPosted: Mon Mar 12, 2012 12:57 pm 
Joomla! Intern
Joomla! Intern

Joined: Thu Sep 27, 2007 1:24 am
Posts: 62
Yes that is the idea exactly.

What I'm finding is that many of the theme shops have seemingly lost touch with the user community and develop fat, lethargic themes with a surplus of bells/whistles enabled which might be acceptable on an ultra-fast connection, but are deal-killers for Joe the Plumber. Unless you are a Joomla designer/developer, sourcing out the how-to's is a real challenge especially if the themer is unresponsive.

Besides the mootools stuff I'm also seeing other stuff including fonts coming through google api's.

Just because you can, doesn't mean you should... Imagine a world of fast-loading joomla pages!


Top
 Profile  
 
PostPosted: Mon Mar 12, 2012 8:05 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Apr 23, 2010 5:55 pm
Posts: 113
Location: Santa Cruz, California, USA
I agree fervently with you, bobmeetin. Extensions in general can exhibit these problems.

Once you've stopped unnecessary scripts from loading, you might want to try out an extension to minify and concatenate your remaining scripts and stylesheets. I couldn't get any of the Joomla extensions to work for me, for some reason, but I set up Google's Pagespeed module for Apache to do the same thing, and it works a treat and makes a big difference in load time.

_________________
Jessi Hance
Cruzio Internet


Top
 Profile  
 
PostPosted: Mon Mar 12, 2012 11:46 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Apr 23, 2010 5:55 pm
Posts: 113
Location: Santa Cruz, California, USA
I have my own question. ionut, or anyone, do you know if there's a way to unset /media/system/js/modal.js ? I tried this same method but it has no effect.

_________________
Jessi Hance
Cruzio Internet


Top
 Profile  
 
PostPosted: Tue Mar 13, 2012 2:32 pm 
Joomla! Intern
Joomla! Intern

Joined: Thu Sep 27, 2007 1:24 am
Posts: 62
I have a feeling this is going to depend somewhat on the theme shop and how they set up their framework. 3-4 years ago before many of the theme shops got into their own version of a framework the "~/www/templates/$template/index.php" was the master. Now you see many variations of how that file is used to include their specific framework. Life has gotten complicated. I did some massive googling and found this code as another way to disclude some JS:

$search = array('mootools', 'caption.js','core.js');
// remove the js files
foreach($this->_scripts as $key => $script) {
foreach($search as $findme) {
if(stristr($key, $findme) !== false) {
unset($this->_scripts[$key]);
}
}
}

You could add mootools-more.js to the list. Unfortunately editing the $template/index.php file doesn't always seem to work and I'm sure the answer is buried in one of the themers' framework files. I have asked some for tips but they are quite lethargic to reply.

Depending on the themer you might be able to configure this stuff in the template parameters. Look for things like overrides and stuff. To really get the skivvy you may need to go into the parameters and turn off any/all cacheing, minimization etc to get the full picture of all files getting included. Then look through the template parameters for anything looking relevant. This may help sorting out the likes of:

mootools
jquery
google apis
facebook connect
fonts
etc...

Sure the cacheing and optimization may help, but ridding the site of what you or your client really doesn't need for the service type is a bonified service. By using the above techniques I was able to strip down a slow template from about 1200 KB to just over 100 KB. Now I go backwards and plan to selectively add back what the client will need. The second trick may include add some if/else statements to test the page for a specific ID or component option, etc and if yes, then load the extra. Kind of like an override...


Top
 Profile  
 
PostPosted: Tue Mar 13, 2012 3:57 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Apr 23, 2010 5:55 pm
Posts: 113
Location: Santa Cruz, California, USA
bobmeetin wrote:
By using the above techniques I was able to strip down a slow template from about 1200 KB to just over 100 KB....

That is truly impressive!

Wouldn't it be great if template and extension developers would compete on efficiency and speed, instead of bullet lists of hundreds of features...

_________________
Jessi Hance
Cruzio Internet


Top
 Profile  
 
PostPosted: Fri Aug 10, 2012 7:19 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 03, 2012 11:07 pm
Posts: 44
Hi Jessihance or bobmeetin,

In which file/folder/line exactly did you put the above code?
I don't know too much about this but I'm having the exact same issues, my website it's too slow and I'm looking to disable all following files:
mootools-core.js
core.js
caption.js


I also noticed my web page analysis says I have a lot of CSS files, but my current template actually have only 1...however I noticed the web is uploading the following CSS files from Joomla:
system.css (this one is being uploaded twice)
general.css

Is there a way to disable these ones as well???

I'd appreciate your kind advice!!! Thanks a lot...


Top
 Profile  
 
PostPosted: Mon Aug 13, 2012 5:02 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Apr 23, 2010 5:55 pm
Posts: 113
Location: Santa Cruz, California, USA
moongirl80 wrote:
Hi Jessihance or bobmeetin,
In which file/folder/line exactly did you put the above code?

Hi moongirl80,

Any code would go in the main index.php file of your Joomla template. This file should be in:
Code:
yourjoomladirectory/templates/yourjoomlatemplate/index.php


Best of luck! - Jessi

_________________
Jessi Hance
Cruzio Internet


Top
 Profile  
 
PostPosted: Mon Aug 13, 2012 6:24 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 03, 2012 11:07 pm
Posts: 44
Hi Jessihance,

Thanks a lot for your reply!
Sadly, I tried to use both codes (ionut's and bobmeetin's) by copying them into my template index.php file, right before starting the html code, in the php code area (as stated in ionut's post), however, nothing seems to be working, and the 3 files (mootools-core.js ; core.js ; caption.js) are still being read.

Any idea?!

Thanks...


Top
 Profile  
 
PostPosted: Mon Aug 13, 2012 6:40 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Apr 23, 2010 5:55 pm
Posts: 113
Location: Santa Cruz, California, USA
Hi moongirl80, I'm sorry, I have no idea. Keep playing around with it, but take a break when you get too frustrated? Maybe come back to it tomorrow? That's what I do when I get stuck.

Sorry, :(

Jessi

_________________
Jessi Hance
Cruzio Internet


Top
 Profile  
 
PostPosted: Mon Aug 13, 2012 11:25 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Jan 03, 2012 11:07 pm
Posts: 44
:( Well... thanks a lot Jessi for your support, I will do so... I hope something better will come up with a clear mind!!!

Cheers... :)


Top
 Profile  
 
PostPosted: Mon Sep 17, 2012 8:33 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Nov 21, 2010 6:09 am
Posts: 14
Thanks for every one specially jessihance .

I have anther idea which not remove them from my site just host them in the fastest place like googol files Or drop-box .
which is in between plan 8) ,I meant not remove them bez My template needs them but they are heavy so I do it before (joomla 1.5) and it was a decent way

I try to use this line :

unset (JFactory::getDocument()->_scripts['/media/system/js/mootools-more.js']);

then I put this directly but it did not worked :(

isset (JFactory::getDocument()->_scripts['http://dl.dropbox.com/u/10XXXXXX/mootools-more.js']);

I don’t know why :-[

Any ideas ?


Top
 Profile  
 
PostPosted: Mon Sep 17, 2012 9:06 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Nov 21, 2010 6:09 am
Posts: 14
I found it Eureka ! :pop .

If someone interesting to know here is the details :



$doc =JFactory::getDocument();
unset($doc->_scripts[$this->baseurl . '/media/system/js/mootools-core.js']);
$googel_code['https://ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-yui-compressed.js'] = array(‘mime’ => ‘text/javascript’, ‘defer’ => false, ‘async’ => false);
$doc->_scripts = array_merge($googel_code, $doc->_scripts);



Again ,Thanks for every one who share and care (Brainstorming, Always better way to do things ;) )

Cheers !


Top
 Profile  
 
PostPosted: Mon Sep 17, 2012 9:22 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Nov 21, 2010 6:09 am
Posts: 14
Google Hosted Libraries - As Googel said Make the Web Faster

Chose from here : :

https://developers.google.com/speed/libraries/devguide

Directly for Mootools :


https://developers.google.com/speed/libraries/devguide#mootools


Top
 Profile  
 
PostPosted: Sat Nov 24, 2012 4:27 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Nov 18, 2012 9:20 am
Posts: 2
Raed911 wrote:
I found it Eureka ! :pop .

If someone interesting to know here is the details :

$doc =JFactory::getDocument();
unset($doc->_scripts[$this->baseurl . '/media/system/js/mootools-core.js']);
$googel_code['https://ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-yui-compressed.js'] = array(‘mime’ => ‘text/javascript’, ‘defer’ => false, ‘async’ => false);
$doc->_scripts = array_merge($googel_code, $doc->_scripts);



Hi Raed, where did you put the code exactly?
What is going to happen if the library version change?

I really appreciated your help, is just for my better undestanding.

Thanks to everyone,
Deep


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ] 



Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group