• Resolved Steven

    (@spstieng)


    I’ve added a few plugsins like SimplwViewer, Google Calendar and Image manager. When I looking at the HTML source, I discovered a lot of javascripts.

    Having a lot of javascripts in the header is not good if you want to optimize the site for the search engines.

    This code <?php wp_head(); ?> generates a lot of code, and most taken from plugins.

    How can I alter this to have the <scripts> be displayed in the footer rather in the header?

    I have looked into general-template.php to see if I could discover anything. The only thing I found was this:

    function get_header() {
    	do_action( 'get_header' );
    	if ( file_exists( TEMPLATEPATH . '/header.php') )
    		load_template( TEMPLATEPATH . '/header.php');
    	else
    		load_template( ABSPATH . 'wp-content/themes/default/header.php');
    }

    Any suggestions anyone?

Viewing 3 replies - 1 through 3 (of 3 total)
  • This has to do with plugins inserting their needed javascript to work.
    And the correct placement is between your <head> tags in header.php if they are linking to a .js file

    Most won’t work if you put them in the footer.php, because the js scripts need to set vars and functions before call them inside the <body> tags. Another matter is if those plugins just fill the head with javascript code… I think that’s a problem with how the plugin is coded.

    I’m not an expert in JS but probably you will get a proper explanation from someone with more knowledge.

    Thread Starter Steven

    (@spstieng)

    Yeah, call to .js scripts needs to be in the header.
    But actual javascripts should be put in the footer if possible.

    I’ll leave it be for the moment.

    Thanks.

    Having a lot of javascripts in the header is not good if you want to optimize the site for the search engines.

    …that’s crap.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘moving scripts from header’ is closed to new replies.