WordPress optimization tricks offers you some uncommon and common hacks to optimize the Page Loading speed specific to WordPress files only. As basically only few (versus the need) are interested and fully active in WordPress core development, some features actually reflects the need of one developer as a human plus some are not possible to deliver as customized version for your website or domain, so this is not the fact that – this WordPress optimization tricks guide is going to Fix some bugs. There are definite bugs like abnormally growing WP_commentmeta Table Database Size which we have fixed in the linked guide, but most of these falls among modification or rather an average user are not supposed to use these tricks.
WordPress Optimization Tricks : Understanding and Not Understanding
Understanding and not understanding can be very relative ! Understanding Page Loading Speed is important, more important is to really perform some basic and advanced settings, like we described in WordPress 3.6 on Rackspace Cloud Sites and W3 Total Cache 0.9.3 Plugin, which is relevant now at the time of writing this article. Not understanding why and how WordPress Works with which intention is most important.
There are many themes available, which basically makes WordPress to act badly. One of the known manufacturer
of such Themes is Elegant Themes, its ugly for the structure. More badly coded Themes can be found in Theme Forest. Understanding the basic facts about WordPress Theme is important. Except few Theme and Theme Frameworks, all basically are dangerous by coding. StudioPress Genesis, Thesis, Woo Themes, some themes of Templatic, all default official Themes are the standard. StudioPress Genesis definitely the best at this time, but unfortunately Free option is not present, so take the default WordPress Theme’s your custom Child Theme as the Standard for the mass. All tricks will work for these mentioned themes.
---
WordPress Optimization Tricks : The PHP Files
Obviously, you WordPress Backend mast be tweaked for faster performance. Backend here is the FTP files of WordPress not the server side. Server optimization can not be named as WordPress Optimization Tricks but possibly as PHP-MySQL Web Software Optimization Tricks. Lesser these are used in Theme Template is better :
1 2 3 4 5 | if (is_page ()) {} elseif (is_home ()) {} elseif (is_single (1067)) {} elseif (is_single ()) {} elseif (is_archive ()) {} |
UTF-8 meta, is usually fetched by :
1 | <meta charset = "<php ??bloginfo ('charset')?>" /> |
Which can be replaced by :
1 | <meta charset = "UTF-8"> |
WordPress, by default has utf8 (or closer to it) in wp-config.php file, not UTF-8. That is a known bug which creates issue by adding odd characters after server migration. This is a thing, which is important to remember. In the same way like meta charset, others can be modified or rather customized, like :
1 | <Link rel = "pingback" href = "<php ??bloginfo ('pingback_url');?>" /> |
It is quite obvious that these will be better :
1 | <Link rel = "pingback" href = "http://your-site.com/xmlrpc.php" /> |
To simplify the code, it is also highly advisable to remove the empty blocks. They are often used to target an element with CSS or javascript. It is also interesting to minimize unnecessarily nested codes, for example in the case where you have a happy div that contains only a div class named article. Dom Monster is a great tool for this purpose :
1 | http://mir.aculo.us/dom-monster/ |
Another kind of tool is Visual Event :
1 | https://github.com/DataTables/VisualEvent |
Another is available for CSS Stress Testing :
1 | https://github.com/andyedinborough/stress-css |
Also consider to clean lines of unnecessary code added in the WordPress header : they bring nothing to the visitors or search engines. To disable these additions, copy the code into the functions.php file of WordPress Theme :
1 2 3 4 5 6 | automatic_feed_links (false); remove_action ('wp_head', 'wp_generator'); remove_action ('wp_head', 'wp_shortlink_wp_head', 10, 0); remove_action ('wp_head', 'wp_dlmp_l10n_style'); remove_action ('wp_head', 'rsd_link'); remove_action ('wp_head', 'wlwmanifest_link'); |
You will get more on WordPress Codex.
WordPress Transients API offers a simple and standardized way of storing cached data in the database temporarily by giving it a custom name and a timeframe after which it will expire and be deleted. This allows in particular to avoid recalculating which are identical on all pages of your site or have little interest in being modified in real time. It may be, for example the list of recent comments, links from your blogroll or a list of keywords related to an article. Feel free to know what content should be in transient, knowing that it is up to you to determine how long each data will be cached. Reference :
1 | http://codex.wordpress.org/Transients_API |
The operation of a transient is quite simple. For each, you ask WordPress to retrieve the associated transient. If it does not exist or no longer exists, you will then generate the transient with a simple echo (for example). Caching using the WordPress Transients API is a clever trick.
We will avoid Javascript tricks in this guide. Previously, WordPress had a native system cache which was enabled with the following line:
1 | define ('ENABLE_CACHE', true); |
Unfortunately, it does not work since version 2.5. However, cache plugins add this line for cache function :
1 | define ('WP_CACHE', true); |
We are talking about wp-config.php file now. People know many wp-config tricks, but less known fact – using other domain names, allows to accelerate the loading time of the data, only problem is, WordPress sends a useless cookie for each of these queries. To avoid this, use these two lines of code in the wp-config.php file:
1 2 | define ('COOKIE_DOMAIN', 'www.mysite.com'); define ("WP_CONTENT_URL", "http://static.yourdomain.com"); |
People, including many developers do not understand the usage. The first is the URL of your site. The second is that the location of your static files. In the example above, it is a subdomain but it may be another URI. Other all things are known by the advanced users.
Tagged With wordpress optimization , wordpress optimization mysql php , wordpress php optimization