Optimized wordpress header : Cleanup unwanted element

Categories: Design, SEO

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:

wordpress

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:
[code lang="html"]

[/code]

The tag :

[code lang="html"] [/code] 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

[code lang="php"]remove_action( 'wp_head', 'feed_links_extra', 3 );[/code]

Remove links to the general feeds: Post and Comment Feed

[code lang="php"]remove_action( 'wp_head', 'feed_links', 2 );[/code]

Remove the link  EditURI link

[code lang="php"]remove_action( 'wp_head', 'rsd_link');[/code]

Remove  Windows Live Writer manifest file

[code lang="php"]remove_action( 'wp_head', 'wlwmanifest_link');[/code]

Remove Index Link

[code lang="php"]remove_action( 'wp_head', 'index_rel_link');[/code]

Remove wordpress Generator

[code lang="php"]remove_action( 'wp_head', 'wp_generator');[/code]

** 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

[code lang="php"]remove_action( 'wp_head', 'parent_post_rel_link');remove_action( 'wp_head', 'start_post_rel_link');remove_action( 'wp_head', 'adjacent_posts_rel_link');[/code]

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:

[code lang="php"]wp_deregister_script('jquery');wp_head();[/code]

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 [code lang="php"]add_action('wp_head', 'plugin_function_here');[/code] after you do know the name of the plug-ins function just go back to your function.php file and include this code: [code lang="php"]remove_action('wp_head', 'plugin_function_here');[/code]And it will work fine.

Hope this discussion may help you guys. Please let me know if I missed something.

Popularity: 98% [?]

Related post

About the Author

Evan Shajed is a freelance website Developer from London UK. Creative designer working with small business with SME DEVELOPERS Follow his daily activities on: Twitter or Connect with his community on: Facebook

Spread The Love, Share Our Article

Related Posts

There are no related posts on this entry.

Comments

  1. Christer Feb 1, 2010

    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.

  2. Falcon1986 Feb 4, 2010

    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.

  3. Internet Banking Feb 4, 2010

    Just killing some free time on Digg and I found your entry. Not typically what I prefer to read about, but it was definitely worth my time. Thanks.

  4. Evan Shajed Feb 5, 2010

    Thanks Falcon1986…

  5. john Jun 3, 2010

    I’m really banging my head against the wall with this one. For some reason, this simple technique isn’t working for my wordpress blog.

    I simply add the appropriate remove_action() function to the functions.php file in my wp-includes subdirectory, but when I reload the page it’s giving me a fatal error – call to undefined function remove_action().

    I’ve checked the plugins.php file and find that the function is defined in that file. I also check the general-template.php file in the includes directory, and find that the action I’m trying to remove with this function exists & everything is input correctly.

    I’m no expert on php or anything like that, so I’m assuming it’s user error, but I don’t understand what I’m doing wrong, as I’m following the steps outlined.

    Where should I place the function, and how should it be inserted into the file?

  6. Evan Shajed Jun 7, 2010

    Hello John,
    Thanks for your query. Can you please give me the link of your blog? Usually if you want to remove the extra headers remove_action() is the only way which is appropriate. Is there any anything that is causing problem? Did you checked is there any space before and after your tag? sometimes very simple things makes problems.

  7. Van Man Jun 24, 2010

    Im looking for someone who knows what they are doing and to clean up my wordpress code drop me a line if you can help.

Trackbacks

  1. IM Website Developer
  2. Shajed Evan
  3. Patrick - HFConcepts
  4. Optimizing Your Wordpress Blog

Add a Comment

Required

Will not be published. Required

Optional