• Mar
  • 22

PHP Speedy Wordpress Plugin Version 0.4

Isn't Easter great? Some quality time off work to spend with family and friends. Or, alternatively, to sit at your PC and work on a Wordpress plugin. I think you'll be able to guess from this release which option I chose.

The big feature of this release (0.4) is that PHP Speedy will now handle standard JavaScript libraries. Previous releases suffered from problems when a plugin used a JavaScript library such as Prototype/Scriptaculous. Also, I have noticed that some plugins include their libraries directly, which means that if more than one plugin calls the same library it is included (and downloaded by the user) more than once. For fun, I tested this out.

Too Many Includes

This is what can happen. A 8.4 second download of 576KB!

With PHP Speedy turned on and handling the libraries this what happens:

Correct Amount of Includes

I thought that was quite funny.

Install

The plugin is a standard Wordpress plugin install - just copy the entire php_speedy_wp folder into your Wordpress plugins folder. Activate the plugin via the "Plugins" menu, then go to Options -> PHP Speedy.

You should then:-

  • Configure PHP Speedy as you see fit, and click the "Set Options" button at the bottom on the configure screen
  • Test the configuration
  • Finally, activate PHP Speedy on its own activation screen. This is separate from the WP Plugin activation.

Download

You can download PHP Speedy WP Wordpress Plugin here: PHP Speedy WP 0.4.7

Changelog

0.1 - Initial Release
0.2 - Fixed bug in ignore (thanks Jeromy)
0.2.1 - Changed control of when plugin loads
- Fixed problem with space on ignore list
0.2.2 - Really fixed bug in ignore (thanks Steve)
0.3 - Added write of debugging info
- Now works on more pages
0.4 - Added Speedy handling of plugin libraries
- Wordpress exclusively handles gzipping
- Compressed files now appear first in document
- Fixed bug in debugging info write
- Made compressed files include at start of head
0.4.1 - Doesn't die if WP_Scripts class not present
0.4.2 - Fixed bug if no css or js in head
0.4.3 - Fixed is_* functions for all versions
0.4.4 - Fixed display for trackbacks (thanks Steve)
0.4.5 - Added check for empty POST array (thanks Jeromy)
0.4.6 - Updated test page to show use of PHP Speedy standalone
0.4.7 - Updated for WP 2.6

Having problems?

  • If it seems PHP Speedy has had no effect at all
    If you view your source code, and it looks exactly the same as it did before you activated Speedy please try the following:

    • First, make sure you really did activate Speedy. Make sure you click the 'Activation' button in Options | PHP Speedy | Activate.
    • Look in the cache directory in the PHP Speedy plugin folder. If there is a text file called 'debugging_info.txt' please email it to me (leon at aciddrop.com). Please include the version of Wordpress you are using and the URL of the site (is it's public).
  • If PHP Speedy breaks a plugin
    If another plugin stops working please try the following:

    • Set the PHP Speedy configuration to use any standard JavaScript libraries that are in use by your plugin.
    • Try adding to the ignore list in PHP speedy all the .js files that your plugin uses. If you don't know what these files are, search the plugin's directory for .js files.
    • Let me know in the comments whether this worked or not (in either case).
  • If PHP Speedy breaks something else
    • Turn off PHP Speedy. View the source of your page and save it to a text file.
    • Turn on PHP Speedy. View the source of your page and save it to a text file.
    • Email me (leon at aciddrop.com) a description of the problem, both text files and the contents of the cache folder in the PHP Speedy plugin directory.

Known issue with wp-cache/WP Super Cache

I managed to do some proper testing with PHP Speedy WP and wp-cache and WP Super Cache. With all the buffer functions going on, the plugins get confused. I found that this could be fixed by amending the wp-cache-phase2.php file in the wp-cache/wp-super-cache directory. Just find the line that says: if ($new_cache) { and add this before it:

CODE:
global $cache_filename;
$mtime = @filemtime($cache_path . $cache_filename);
if( !((!$file_expired && $mtime) || ($mtime && $file_expired && (time() - $mtime) <5)) ) {
$new_cache = true;
}

PHP Speedy WP should then work with the caching plugins.

What's to come?

The eventual plan is to automatically improve all elements that could be slowing down your page (and causing that terrible Y-Slow rating). Next on the list are document images and CSS background images - so make sure you subscribe to my blog to be the first to find out about new updates.


Related posts

Posted by admin in php, wordpress
trackback
 

  • Mar
  • 22
Perry
Perry

I get this error...

Fatal error: Class wp_scripts_extend: Cannot inherit from undefined class wp_scripts in /home/perig1/public_html/hoboken411/wp-content/plugins/php_speedy_wp/php_speedy_wp.php on line 40

  • Mar
  • 22
admin
Leon

Thanks Perry - what version of Wordpress are you using?

  • Mar
  • 23
Perry
Perry

Sorry I didn't mention: 2.0.11

Yes, I know.. not the latest.. but I need it in order to work with my quote.php plugin, which is crucial for my site...

  • Mar
  • 23
admin
Leon

Perry - I have made some changes so it should now also work with versions less than 2.1. However, the new JavaScript libraries feature will be disabled. Please download version 0.4.1 (you should only need to replace the php_speedy_wp.php file)

  • Mar
  • 23
David
David

Sorry, but the latest version of the PHP Speedy plug-in has caused Lightbox to break again.

Firebug shows a JavaScript error of...

lb_path is not defined

  • Mar
  • 23
admin
Leon

David - thanks for letting me know. The problem seems to be that lightbox adds the following line to your source:

<script type="text/javascript"> lb_path = "http://www.artiss.co.uk/wp-content/plugins/lightbox/"; </script>

Speedy doesn’t touch inline javascript, so it leaves it there and therefore the order in which the variables are defined becomes incorrect: lightbox looks for the lb_path variable before it is defined.

One solution would be to use this version of the plugin http://stimuli.ca/lightbox/ This is the one I used during testing and it didn’t define lb_path in that way. Another would be to open lightbox.js and define lb_path there. Just add lb_path = "http://www.artiss.co.uk/wp-content/plugins/lightbox/"; at the very top.

If futher plugins suffer from this problem I may add in an option for Speedy to include inline JS.

  • Mar
  • 23
Perry
Perry

"However, the new JavaScript libraries feature will be disabled."

- That stinks! How come?

I'll give 0.4.1 a shot now.. Thanks for your help!

  • Mar
  • 23
Perry
Perry

Uh oh...

I get this error now:

Fatal error: Call to undefined function: is_tag() in /wp-content/plugins/php_speedy_wp/php_speedy_wp.php on line 496

  • Mar
  • 24
Manne
Manne

I still get the "PHP Speedy didn't find any JavaScript or CSS" message on testing. WPMU 1.2.5

  • Mar
  • 24
admin
Leon

Perry - it uses a wordpress class called WP_Scripts to insert the libraries. This is only available from version 2.1. Looks like is_tag function isn't available in your version either. I'll look into it. For the time being just remove || is_tag() from the source code of php_speedy_wp.php

Manne - I never saw the full post of your head code. However, from what I did see it looks like you are using @import and inline CSS. PHP Speedy doesn't support @import and doesn't touch incline CSS. So if you don't have any JS or CSS linked to via link or script tags then there's nothing for Speedy to do.

  • Mar
  • 25
Perry
Perry

Hey Leon,

quick question...

Will you eventually be upgrading the old non-plugin version of PHP speedy as well?

I'll try 0.4.2 again tonight, and remove the code as you specified. I wish someone upgraded the now-abandoned quoter.php plugin to work with versions of WP 2.1 and higher.. I really should be on 2.5, but it's holding me back!

I'll let you know how it works. I'd love to be able to use the libraries, because many identical scripts are called.. it'd be a huge overhead saver.

Perry

  • Mar
  • 26
admin
Leon

Perry - yes I definitely will. I've been maintaining compatibility will the non-plugin version as I go along so I want to go back and update when I get a chance. I've updated also so is_tag shouldn't be a problem (0.4.3).

It's a pity about quoter.php. What does it do? Maybe there's a more up-to-date plugin around that does the same?

  • Mar
  • 26
Perry
Perry

Nope... that plugin was abandoned by the author, and no one else has picked it up.... it's a great piece of functionality that readers use constantly.

I'll try the .4.3 version tonight. Here's a question, though.

I use a very unique theme. My various pages don't all use the index.php file... for instance, reading a single article uses the archives.php file...

When I used the manual php_speedy, I had to put the code in various php files, such as:

index.php
archive.php
category.php

... and so on...

Where does the wordpress plugin do all it's "action?" The one thing that is consistent in my theme, is that header.php, sidebar, etc. are all within the index, archive, category, etc...

So, it's unorthodox compared to the standar K2 themes that are out there... is that part of the reason none of my files are being cached?

Not sure I'm explaining properly, and if you'd rather me discuss offline via email I will..

  • Mar
  • 26
Manne
Manne

Leon: I'll try again then!

CODE:
Testar min blog

<!-- Start Of Rating Script -->

  • Mar
  • 26
admin
Leon

Perry - it does its work at the template_redirect hook, which is called just before any of your template files are included. Then it looks at the $wp_query object to see what type of page it is. This is the relevant bit of code:

CODE:
if((
!empty($wp_query->is_single)
|| !empty($wp_query->is_preview)
|| !empty($wp_query->is_page)
|| !empty($wp_query->is_archive)
|| !empty($wp_query->is_date)
|| !empty($wp_query->is_category)
|| !empty($wp_query->is_tag)
|| !empty($wp_query->is_search)
|| !empty($wp_query->is_home)
|| !empty($wp_query->is_404)
) && count($_POST) == 0) {
$speedy_controller = new php_speedy_wp_controller(array('admin'=>$this));
$speedy_controller->run();
} else {
if(empty($wp_query->is_feed) && empty($wp_query->is_author) && empty($wp_query->is_comment_feed) && empty($wp_query->is_trackback) && empty($wp_query->is_comments_popup) && empty($wp_query->is_admin) && empty($wp_query->is_attachment) && empty($wp_query->is_robots)) {
$this->write_debugging_info();
}
}

I'm not 100% sure of the code on all version so please do test and let me know.

Manne - you can always email it to me leon at aciddrop.com

  • Mar
  • 27
steve
steve

Leon,

I responded to your question from last week a couple days ago. I'm almost positive it was in this post. I think I put in a different email than normal and it got stuck in moderation.

In case it didn't, to answer your question about what is broken in IE, it is quite a few things, but the most noticeable ones are a 1px gap at the right side of the header, the search box isn't vertically centered, and the flickr gallery is offset way to the right. I didn't have the css options on when you probably looked last week but they're on now. If you switch between IE and FF you can see the differences.

Test blog

Also, did have a chance to look at the All in One SEO plugin issue?

Thanks...Steve

  • Mar
  • 27
steve
steve

Leon,

Scratch that last comment. I installed your new version and the issues with the conditional comment IE css is working now as well as the All in One plugin.

Don't know if you addressed those in the newest release, but regardless, thank you!

Steve

  • Mar
  • 27
Curtis

I got a fatal error on the test page from using up all of the 32mb php memory. I increased it to 64mb and it works without a problem.

I was just wondering if this was normal or if it should have worked with the 32mb memory size?

  • Apr
  • 1
anung
anung

is this plugin work for WP 2.5?
and is googlebot can read the compressed page?

  • Apr
  • 1
Perry
Perry

.4.3 worked for my old WP version... while not as complete, there was still some improvement.

Any chance the libraries can ever work on a 2.0.x version?

Good work across the board otherwise!

  • Apr
  • 2
Epic Alex :: Web Design

This is without a doubt a great plugin, but I have one problem;

I use All in One SEO Pack on my site, and the speedy php plugin has stopped the homepage title from being rewritten.

I had this exact same problem before when I had no wp_head call in my head section, is this plugin doing something that might stop that working correctly?

my site is http://epicalex.com/ if you want to take a look

  • Apr
  • 3
admin
Leon

Steve - I didn't do anything with regards to the conditional comments, but I did make a change for the All in One plugin. Glad it's working.

Perry - I'm afraid not. I think it's be more worthwhile for you to work out a way to upgrade your blog. If it's a business blog, remember I'm for hire (http://aciddrop.com/about) as a web developer and could give you a quote on the upgrade.

  • Apr
  • 3
admin
Leon

Alex - thanks. Does it work OK if you turn off page gzipping?

  • Apr
  • 3
tony

Hi Leon - PHP Speedy looks great, but after enabled wp frontend and backend pages are taking over 60 seconds per page load. (really slow). Perhaps it's not wordpress 2.5 compatible yet? I did try the wp-cache workaround, and also disabled wp-cache. Looking forward to getting this working.

Thanks for the cool plugin!

  • Apr
  • 4
Jeromy
Jeromy

leon - did you get my email with my log files?

  • Apr
  • 4
admin
Leon

Jeromy - sorry, yes I did. I have replied just now.

  • Apr
  • 6
Perry
Perry

What is the version upgrade process?

De-activate PHP_Speedy, then deactivate plugin, remove directory, start over again?

A short list of "to-do's" would be helpful.. I get nervous doing things without checking first..

Thanks!

  • Apr
  • 8
Alessandro Ronchi

I cannot activate it on my wordpress 2.5. If I try, it gives me 404 after the activation page (the url is: http://www.alessandroronchi.net/wp-admin/plugins.php?action=activate&plugin=php_speedy_wp%2Fphp_speedy_wp.php&_wpnonce=9e3b0ddd16)

  • Apr
  • 8
admin
Leon

Perry - just deactivate Speedy and overwrite all the files in the directory (apart from libs/php_speedy/config.php if you want to save your current config). Then test and reactivate.

Alessando - what's the URL when you activate another plugin?

  • Apr
  • 8
admin
Leon

tony - sounds like a strange one. I've tested with 2.5 on a couple of sites and all was OK. Interesting. One thing that occurs to me is that in the backend PHP Speedy does a scan of your plugins directory to look for JS libraries. You don't somehow have thousands of files in there do you?

  • Apr
  • 9
Victor F. Ruiz

I hava to JavaScritp files that I want to include but it says that "Cannot compress external files" How can I add it to compress?

Thanks!

  • Apr
  • 24
..::DeuceD::..

Hey Leon, great plugin! Works with WP2.5 perfect, thx!

  • Apr
  • 26
Manne
Manne

How do I make speedy do it's magic on in the wp admin interface? I'd really like to speed up the post panel...

  • May
  • 8
rey
rey

Has anyone tried this on WP 2.5.1? I'm really interested in giving this a go but don't want to break my site. I also have the AIOSP and WP-cache plugins running. Keep up the great work Leon. I may download version 0.6?

  • May
  • 14
Lena

Hi Leon,

I am running on WPMU. My shadowbox Plugin stopped working even after ignoring all shadowbox js files. Besides that, plugin did not seem to have any other effect on my site. when i try to minify, my site simply doesn't show up.

  • May
  • 16
Marina HotForWords

I REALLY want to use your plugin.. but I get garbled pages when I try it!

My site is getting MAJOR traffic and this would really help..but I just cannot get it to work.

Bummer.

Also.. does it actually REMOVE files when activated? In other words, can I do really bad damage to my site by losing all my js and css files? As it says things like "Replaced x file with x file... ".. that scares me.

Thanks,
Marina
http://www.hotforwords.com

  • May
  • 20
admin
Leon

Victor - I'm afraid it doesn't work with external files at the moment. That would be a major new feature, pretty complicated.

DeuceD - thanks.

Manne - You can't at the moment I'm afraid. Good suggest for the next version though.

rey - dowload PHP Speedy WP 0.4.5. I have tried it on 2.5.1, it works fine. You can't really 'break' your site, as it's easy to turn off if it doesn't work properly.

Lena - Were there any changes in the source code of the page before and after turning on PHP Speedy? If you could email me before and after versions of the source, it helps in diagnosing problems.

Marina - try turning off gzip compression. Then at least you won't get a garbled page, and you can see an error message. No, it doesn't actually remove or replace any physical files, so don't worry!

  • Jun
  • 6
Pete
Pete

Bug Found: Version 0.4.6 is eating the data URIs in the stylesheet. For example, if my stylesheet says,

background:url(data:image/gif;base64,[encoded-image-data-goes-here])

php_speedy turns it into

background:url([path-to-theme-directory]/data:image/gif)

We'd want PHP_Speedy to preserve those data URIs. In my case they save me a dozen http requests.

  • Jun
  • 11
uyax

Nice Plugin... I Try To use this plugin......

  • Jun
  • 11
uyax

nice plugins , i Have try to my blog n its working

  • Jun
  • 26
Kaspars

Hi, Leon, just wanted to let you know that the WordPress 2.6 beta has been released and they have significantly changed the WP_Script class. I took some time to go through the changes but still couldn't get it working.

  • Jul
  • 20
Vladimir

Amazing Work!

Do you think you could move compressed files to footer or make an option to select where to load them?

Here is fix for php speedy to work with 2.6

http://konstruktors.com/blog/wordpress/296-php-speedy-plugin-wordpress-2-6/

Comments are closed