WordPress.org

Ready to get started?Download WordPress

Forums

scripts not loaded in the footer (3 posts)

  1. simbian
    Member
    Posted 3 years ago #

    Hello everybody, i put that code to my functions.php

    function add_jquery_tools() {
    	if ( !is_admin() ) {
    		wp_register_script('addons_script', 'http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js', array('jquery'), 'true');
    		wp_enqueue_script('addons_script');
    	}
    	if ( !is_admin() ) {
    		wp_register_script('addons_javascript', 'https://apis.google.com/js/plusone.js', true, '');
    		wp_enqueue_script('addons_javascript');
    	}
    
    }
    add_action('wp_print_scripts', 'add_jquery_tools');

    but both the script i see that are loaded in the head, see HTML source of http://www.digitalking.it instead of footer, even if i set the variable $in_footer to true according to Codex http://codex.wordpress.org/Function_Reference/wp_enqueue_script
    what's wrong?

    Thanks in advice,
    Simone

  2. Mark / t31os
    Moderator
    Posted 3 years ago #

    The first script has jQuery as a dependancy, if another script also has jQuery as a dependancy, and said script loads in the head, then as a result, so will yours.

    The second script does not set the in footer parameter to true, so naturally it appears in the head(the third paramter is set to true, which is for dependancies - and the fourth which is the with footer paramter is an empty string).

  3. simbian
    Member
    Posted 3 years ago #

    thanks for the explanation!

Topic Closed

This topic has been closed to new replies.

About this Topic