Going Mobile

I mentioned the other day that I had “mobilised” this website, so it appears appropriately on, well, mobile phones. The plugin I used in this case is WordPress Mobile Plugin.

However, it’s since occured to me that the ability to actually write entries on my mobile might be handy too (particularly as I now have my Bluetooth keyboard) - the aforementioned plugin doesn’t add that functionality. Some scratching around this morning (including a plugin that simply wouldn’t activate because it caused a “fatal error”) I found something called WPhone Admin Plugin. This works a treat, although it renders it in a very simple wap-style format (which is weird, but according to their forums appears to be the case on the N95).

However, I also tried something called, grandly, “WordPress Ultimate Gamer’s Pack“. It’s supposed to display your page more appropriate on portable devices - specifically the Nintendo DS, Wii and Sony PSP. I activated it and tried it on my Wii… database error. Can’t be good. Deactivated it and all is now well. Hmm.

This mobile malarkey isn’t as simple as you’d think, is it?

PHP Speedy and Lightbox

I’ve talked before about the excellent PHP Speedy application - both a PHP script for your website or a WordPress plugin. However, as with all apps of this type, it doesn’t always “play ball” with everything.

In this case, I use the Lightbox 2 plugin for WordPress and, well, PHP Speedy has a tendency to break it.

So, having spoke with Leon at Aciddrop, I have the following fixes (this works on the current 1.8.2 version of Lightbox 2).

First of all, find the following line in lightbox.php:

$lightboxscript.= “<script type=\”text/javascript\” src=\”".$lightbox_path.”js/scriptaculous.js?load=effects,builder\”></script>\n”;

Replace this with:

$lightboxscript.= “<script type=\”text/javascript\” src=\”".$lightbox_path.”js/effects.js\”></script>\n”;
$lightboxscript.= “<script type=\”text/javascript\” src=\”".$lightbox_path.”js/builder.js\”></script>\n”;

Next, open up lightbox.js and before any of the code, add the line:

lb_path = “http://www.artiss.co.uk/wp-content/plugins/lightbox-2-wordpress-plugin/lightbox/”;

Obviously, you will need to change the path to wherever your lightbox folder is.

And then, as if by magic, all should work. If you find that photos appear but without any buttons, then it’s the second fix (the one to lightbox,js) that fixes this, so look again at this. If the change to lightbox.php doesn’t work then, well, the lightbox won’t work at all (the picture will simply be displayed normally).

Hopefully, this might help someone ;)

N95 apps & mobile internet

Both yesterday and today I’ve been having a bit of a play with applications for the N95 as well as internet access via the phone.

First all, it’s REALLY easy to convert a Wordpress blog like this into a mobile application. The free WordPress Mobile plugin is rather good. It comes with a plug at the bottom for the author, plus 50% of any advertising revenue goes to them too - unless you pay a one-off fee of £25. As I don’t advertise, this isn’t an issue ;)

So, if you now visit my site via your mobile phone you’ll find it display as appropriate for that format.

The screenshot of this is to the right and was created by a very simple free Symbian app.

Now, whilst playing with the aforementioned Mobile plugin, I noticed that they offered a QR barcode to add to each page - scanned by an appropriate mobile phone or PDA, this would link back to the URL of the page. Now, I’d noticed the barcode scanner function on my phone but couldn’t see the use.

Instead of adding one for each page, I’ve instead put one in this blogs sidebar - scan that on your mobile phone and it will give you the general URL of the site - far quicker than typing it in! I can see other uses for this (it can hold all sorts of information, not just URL’s) and I’ve already seen it used in magazine adverts.

There are a number of a QR code generators on the internet, so there’s really no excuse not to dabble!

N95 application wise, I’m also trying out the Nokia Step Counter (yes, yes, I know). What I’m really excited about, though, are a number of apps by a chap named Samir - at the moment they’re all in a closed beta, but he intends to make them freeware once complete. These includes utilities to perform actions if the phone is turned over or shook (I love the idea of turning the phone over at night and it automatically going into a silent profile!).

Lastly, I’ve recently taken delivery of an ultra-slim Bluetooth keyboard, made by iGo. It’s superb and a really good price too - less than half the price of most others. Now, ignoring the fact that they’d decided to put a sticker on it running from front to back, and not one that easily comes off, or the fact that the manual that comes with it is next to useless, it’d heartily recommend it.

However, there are no N95 drivers for it, so you have to use those that are available for the N73. I contacted iGo to find out when they might be available and it would appear that they never will be as the keyboard is no longer being made. So snap them up whilst they’re cheap! And still available!

WordPress Upgrade

I’ve finally got around to upgrading my blog to version 2.5 of Wordpress. Their site recommended I install a maintnenace mode plugin before commencing - it would let visitors know why the site was down. A good recommendation I though. I installed it and activated it. I then did the upgrade. Going to my site displayed the maintenance message… trying to go into admin displayed the maintenance message… in fact I couldn’t do anything but display the message. Arrgghhh. Thankfully deleting the plugin sorted that out.

And apart from that slight panic, all went reasonably well. Haven’t yet explored all the new features but the admin screens all look a lot funkier.

PHP Speedy

In my previous article I discussed various ways to improve website performance. I mentioned PHP Speedy, a script from Aciddrop.

PHP Speedy has 3 main functions…

  1. “Minify” your code, JavaScript and CSS.
  2. GZIP code, JavaScript and CSS.
  3. Add Far_future_expires for JavaScript and CSS

Now, there’s not a lot of documentation on what exactly it does, just how to use it. However, PHP Speedy is based on a number of utilities that the author had been working on, so his blog comments on those can give us a clue.

For a start, PHP Speedy will combine JavaScript and CSS scripts - so if your code references a number of these, PHP Speedy will change it to just the one, reducing the number of server calls.

Here are the options in more detail…

Minify

This is the most unknown of the options, other than the fact that the JavaScript part of this is known to be a version of JSMin.

What we do know is that it reduces your code size by removing redundant code. I contacted the author of PHP Speedy, Leon Chevalier, and he confirmed more of the detail. For CSS files whitespace and comments are removed. For code all leading spaces, tabs and carriage returns NOT preceded by a PHP close tag are removed.

I’m sure this could be more robust - for example why not remove tabs and carriage returns for CSS - but is probably nearly as good as minifying your code beforehand.

So, the big question is, does minifying your code before using PHP Speedy make a difference? Well, I ran one of my sites CSS through the online compressor at CSSdrive - this reduced it by 25%. However, according to Yslow, it made little, or no, difference in speed. The conclusion must therefore be that any compression before using PHP Speedy is a waste of time. This will save a lot of effort long term.

GZIP

GZIP can be activated via your .htaccess file but some people, myself included, may find even this impossible with their current host. There are script options, and I’m assuming this is what PHP Speedy is making use of - it’s certainly performing a GZIP on the code, CSS and JavaScript, as stated.

Far Future Expires

Now, this is the bit I’ve always been afraid of. If used manually, you have to remember to provide files with different filenames whenever they change. Otherwise the previous cached version will be used.

PHP Speedy is clever though - if you remember, it will combine CSS and JavaScript’s (even if there’s just one) and give it it’s own name. This remains the same UNTIL you change any of the files, then the filename is modified. This means YOU don’t have to worry about changing the filename whenever the code changes - PHP Speedy does it for you.

What does this mean? If you haven’t changed any of the JS or CSS files, then it will be cached at the users end.

Conclusion

PHP Speedy is an incredibly well thought out and useful utility - it puts together a lot of the principles from my original article, and does so in a way that’s easy to implement. It does a lot of stuff on the fly saving a lot of time and effort.

It would be nice if there was more information available on what’s it doing, rather than how good it is.

But, the proof is in the pudding, and this very blog is now working with PHP Speedy (all options turned on).

Which reminds me; during the install there are instructions on how to add PHP Speedy to WordPress. This involved adding code to index.php. I found this only worked on the main blog page and no others, but have found that adding the code to the header.php and footer.php instead works a treat.


If you’ve found this article of interest, then a PDF version is available for download below. I’m happy for you to use and distribute this, but please don’t edit it, sell it or generally be beastly.

Download PDF File php-speedy.pdf