UPDATE: Version 0.2 released
In the new theme designed for Gibni.com, one of the main goals is to attain maximum speed and shorter page loading times. This post is for people who have the basics of website optimizations. In this post, I’ll discuss a very popular WordPress Plugin, Global Translator, made by www.Nothing2Hide.net, which is used to provide translated version of your blog to visitors. This plugin improved a lot over time, and it gives better and better results after each upgrade. Latest version till date is 188.8.131.52, which is a stable version.
In the process of optimizing my website, I found out that this plugin consumes a large amount of loading time and keeps pages in a loading state for a long period of time, and it makes many connections busy between the client and the server to download all the flag pictures to the client’s computer. This slows down the page as there’s a limited number of simultaneous connections allowed between the client and the server. On the other side, this increases the ‘account hits’ on shared hosting plans.
To make the plugin and the page load and respond faster, I’ve thought of a solution, which is: instead of the plugin sending multiple small image files, it should send a merged image file containing all the required flag images and generate an image map to build the links.
First of all, I’ll stick to a specific model, which is a single line bar. The functions are easy to understand an you can build any shape you want.
Now I’ve to edit Global Translator’s core to give flag images to the merging script. and then create an image map for the translator bar.
After a lot of tests, I finally figured it out! You can find the code for ‘translator.php’ in the Page.
My modified PHP, will generate a fresh PNG file upon user request and store it in the root directory and then creates an image map to create the links for the translator. The good news is everything remains dynamic and if you change the combination of translations available, the PNG and Image Map will change automatically too!
There are still improvements to be done, for example, forcing the code to create the PNG file in the plugins directory and not the site root! So, if you have any ideas, just let me know!