Optimized wordpress header : Cleanup unwanted element
As a new blogger I am going through lots of usability and optimization difficulty with my current site theme. I always follow source file how dose it really look like? Whether it is optimized or not? If it is properly formatted? How my template is effecting by plug-ins?
I just tried some new search on how to optimize or remove unwanted elements from header file? I really liked three post. Bellow are the three Links from which I have taken references for this post:
- Removing wp_head() elements (rel=’start’, etc.)
- Cleaning up wp_head
- Remove unwanted WordPress header elements
I found these post really helpful and like to share some of my understandings with you:
Problem with wordpress wp_head()
wp_head() is a action hook for plugins which is used in HTML <head> tag in wordpress header.php file. It is used so that plugins can include their additional functionalities within <head> tag if necessary. Now the problem with this wp_head() is that it do have some of it’s own element itself which you can find in view-source page of your template. Have a look:
<link rel="alternate" type="application/rss+xml" title="Ponte en forma. Deporte, salud, nutrición y preparación física. Menecesitas.com &amp;amp;amp;amp;amp;raquo; ¿Es mejor el hielo o el calor? Comments Feed" href="http://www.menecesitas.com/2009/08/26/%c2%bfes-mejor-el-hielo-o-el-calor/feed/" /> <script type='text/javascript' src='http://www.menecesitas.com/wp-includes/js/comment-reply.js?ver=20090102'></script> <script type='text/javascript' src='http://www.menecesitas.com/wp-includes/js/jquery/jquery.js?ver=1.3.2'></script> <script type='text/javascript' src='http://www.menecesitas.com/wp-content/themes/fusion/js/fusion.js?ver=2.8.4'></script> <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.menecesitas.com/xmlrpc.php?rsd" /> <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://www.menecesitas.com/wp-includes/wlwmanifest.xml" /> <link rel='index' title='Ponte en forma. Deporte, salud, nutrición y preparación física. Menecesitas.com' href='http://www.menecesitas.com' /> <link rel='start' title='No juegues con tu salud, invierte en ella' href='http://www.menecesitas.com/2009/02/27/no-juegues-con-tu-salud-invierte-en-ella/' /> <link rel='prev' title='Dieta baja en grasas y azúcares para los excesos del verano' href='http://www.menecesitas.com/2009/08/25/dieta-baja-en-grasas-y-azucares-para-los-excesos-del-verano/' /> <link rel='next' title='Prepara tu primer triatlón' href='http://www.menecesitas.com/2009/08/27/prepara-tu-primer-triatlon/' /> <meta name="generator" content="WordPress 2.8.4" />
The tag :
<link rel="alternate" type="application/rss+xml" title="Ponte en forma. Deporte, salud, nutrición y preparación física. Menecesitas.com » ¿Es mejor el hielo o el calor? Comments Feed" href="http://www.menecesitas.com/2009/08/26/%c2%bfes-mejor-el-hielo-o-el-calor/feed/" />
is unnecessary if you do use different rss feed element like Feed Burner in your blog. Moreover it conflicts the original title tags as well. In some cases few social networking services like “StumbleUpon” get confused which title it should follow!
How to remove?
Remember removing the wp_head() element is simply designers choice. It is up to them. If you really want to use core Jquery link given by wordpress, want to write your blog using Windows Live writer then you should not remove these elements. One simple solution might be just remove the wp_head() from your header.php file. In that case it may hamper your template because these Action hooker helps your template to work smoothly. What we can do is, to remove each single element inserting few codes in your function.php file.
Open your function.php from your Editor from wordpress admin or with notepad from your local PC. Now add following codes according to your interest. I have removed all of them because I already had substitutes for my template and most of them were useless for me.
Remove the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links_extra', 3 );
Remove links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'feed_links', 2 );
Remove the link EditURI link
remove_action( 'wp_head', 'rsd_link');
Remove Windows Live Writer manifest file
remove_action( 'wp_head', 'wlwmanifest_link');
Remove Index Link
remove_action( 'wp_head', 'index_rel_link');
Remove wordpress Generator
remove_action( 'wp_head', 'wp_generator');
** please be aware removing this link means you might have problem while upgrading your wordpress automatically form your admin dashboard.
Remove Start, Prev and current post link
remove_action( 'wp_head', 'parent_post_rel_link');remove_action( 'wp_head', 'start_post_rel_link');remove_action( 'wp_head', 'adjacent_posts_rel_link');
Remove Additional Jquery Link
If you include all your jquery script source manually in your <header> tag in that case self included jquery reference is an excess for you. We do have on function wp_deregister_script(‘jquery’) , But the we cant include this one in function.php file. It is because it inherit code wordpress admin panel jquery functionality. In that case (Thanks to Falcon to notify us) we just need to open our header.php file and include the code just above wp_head(), as follow:
wp_deregister_script('jquery');wp_head();
Thats all the basic wp_head() element you may want to remove to keep your <head> tag clear. Though some plug-ins will contradict with their own generated script like JavaScript or style sheets in that case you have to go more deeper. You just need to open that plug-ins main php file and try to find
add_action('wp_head', 'plugin_function_here');
after you do know the name of the plug-ins function just go back to your function.php file and include this code:
remove_action('wp_head', 'plugin_function_here');
And it will work fine.
Hope this discussion may help you guys. Please let me know if I missed something.
Popularity: 33% [?]
Comments (6)



























New Blog post Optimized wordpress header : Cleanup unwanted element http://bit.ly/4MQyqD …
OPTIMIZED WORDPRESS HEADER : CLEANUP UNWANTED ELEMENT http://bit.ly/4Xi540 #wordpress
RT @evan2all OPTIMIZED WORDPRESS HEADER : CLEANUP UNWANTED ELEMENT http://bit.ly/4Xi540 #wordpress
I have been awaiting Google’s web browser’s addons for quite a while … At this point I’ve worked with 8 plugins and am plesantly surprised with the extensions. Firefox 3 has started to slowed with use and the plugins are necessary.
Thanks for the link!
You have really done a great job exploring more about this topic. Will definitely look into implementing some of it on my own websites.
Thanks Falcon1986…