Fiji Web Design
Welcome, Guest
Please Login or Register.    Lost Password?
placing cache script / css higher in the head (1 viewing) (1) Guest
Joomla Speedy Plugin will install the PHP Speedy Library and configure it through the Plugin's parameters.
Go to bottom Post Reply Favoured: 0
TOPIC: placing cache script / css higher in the head
#648
zachariah (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
placing cache script / css higher in the head 3 Years ago Karma: 0  
What people may find is if php speedy is used in its stock form on joomla, it can break some components that also dynamically put code into the header. If a function is called with dependent code that needs to be loaded first, and php speedy is loading the script at the bottom of the head, then it will surely break.

There is a solution - there most likely is a cleaner, happier way to do this I'm sure, however this worked for me.

This code, usually very high up in a template file:

<jdoc:include type="head" />
loads the header files from joomla, the components and modules. What I noticed was that all the javascript was loaded after the title tag making it a good dividing line for me to shoot for. Since the PHP Speedy plugin renders the html code after the jdoc:include tag has long been replaced with code, all we have to do is tell php speedy to render it after the title tag... after all, it has to somehow know where to put its code, so it is just a matter of determining how it knows where to go. The Solution is in the file /plugins/system/php_speedy/compressor.php replace this code on LINE 435:
$source = str_replace($value['location'],"@@marker@@",$source);
with this:
$source = str_replace($value['location'],"",$source);
$source = str_replace('</title>',"</title>\n@@marker@@",$source);
what this is doing is instead of putting the "marker" where the first filename was removed from (first code block), it is instead just removing the code, then the next line is searching for the title close tag, and replacing it with itsself, a new line, and the marker. The marker will then be replaced with the reference to the new cache file later on in the code. This should guarantee that you load the combined Javascript and css before anything the is on the blacklist or that somehow gets excluded. This is a hard-coded hack on the php_speedy compressor core file, which is cool as long as you don't forget about it and update php speedy later on. -Zachariah
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Joomla Downloads

DownloadsDownload our free Joomla! Components, Modules and Plugins.