• Resolved iAyo

    (@iayo)


    hi, the scripts i enqueued in functions.php for my theme using wp_enqueue_script() arent displaying in source code, when site is loaded, indicating that the scripts aren’t being loaded in wp_head().
    i check to see if they are queued with
    wp_script_is('queue')
    it returns true for all of them however
    wp_script_is('to_do') and wp_script_is('done') return false
    here is my code:

    function goldrush_js_enqueue(){
    
    wp_deregister_script( 'jquery' );
    wp_enqueue_script( 'jquery' );//wordpress provided jQuery library
    wp_enqueue_script( 'jquery.tweet', get_template_directory_uri() . '/js/jquery.tweet.js', array('jquery'));
    wp_enqueue_script( 'flexislider',get_template_directory_uri() . '/js/jquery.flexslider-min.js', array('jquery'));
    wp_enqueue_script( 'menujs',get_template_directory_uri() . '/js/menu.js', array('jquery'));
    wp_enqueue_script( 'flicker',get_template_directory_uri() . '/js/jflickrfeed.min.js', array('jquery'));
    wp_enqueue_script( 'quicksand',	get_template_directory_uri() . '/js/custom.quicksand.js', array('jquery'));
    wp_enqueue_script( 'prettyphoto',get_template_directory_uri() . '/js/jquery.prettyPhoto.js', array('jquery'));
    }
    add_action('wp_enqueue_scripts', 'goldrush_js_enqueue');

    please help, its urgent, thanks

Viewing 15 replies - 1 through 15 (of 15 total)
  • URL?

    Why do you deregister ‘jquery’ only to register it again?

    If you deregister is, you cannot simply run:

    wp_enqueue_script( 'jquery' );

    afterward, as the process of de-registering it actually removes WordPress’ reference to it, and it will not know where to find it, so nothing that depends on it will get enqueued.

    You should remove both the following lines:

    wp_deregister_script( 'jquery' );
    wp_enqueue_script( 'jquery' );

    in your function, since you have jQuery listed as a dependency in every-other call… it will be added automatically.

    Oops, good catch, Max. He doesn’t re-register it. He just tries to re-enqueue it.

    Thread Starter iAyo

    (@iayo)

    Hi, Max removed both lines but still no joy.
    However,
    wp_script_is( $handle, $list = 'queue')
    returns true when tested on all the script handles except when the handle is ‘jquery’ where it returns false meaning jQuery library doesn’t get enqueued.

    Also this function returns false on all $handle when $list = ‘to_do’.

    please help…

    Thread Starter iAyo

    (@iayo)

    I wanted to note that when i put
    wp_enqueue_script( 'jquery' );
    at the top of my functions.php file outside the
    function goldrush_js_enqueue(){}
    wp_script_is( 'jquery', $list = 'queue' )
    returns true cant understand why….

    That strikes me as somewhat odd behavior. Is there a plugin, or perhaps some other component of your theme, that might be messing with jQuery registration? Can you post an URL?

    Thread Starter iAyo

    (@iayo)

    its still on my production machine its not live yet but i will install afresh copy of wordpress and try it out

    Thread Starter iAyo

    (@iayo)

    i just put the theme on a fresh install of wordpress and still cant get the scripts to run. Here is the URL:

    https://www.goldrushbeauty.com/

    jQuery is still not being loaded… can you past your functions.php to pastebin so we can look at it…

    Also your header.php as I notice there is some inline script that is being output before the scripts that are being enqueued by WordPress.

    Thread Starter iAyo

    (@iayo)

    I think I will download that theme, as I notice that is including a setup file, @s_ha_dum is right when he says that is odd behaviour…

    I did notice one small issue:

    You are missing a jQuery dependency in

    wp_enqueue_script( 'jquery.tweet', get_template_directory_uri() . '/js/jquery.tweet.js');

    This is however not the cause of the other issue… Will post back in a min when I have looked at the theme…

    Thread Starter iAyo

    (@iayo)

    functions.php posted in pastebin

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    What you’ve posted here will never work as a link (thank goodness too!) but this will.

    https://pastebin.com/pZKrLxRV

    Please see this link for instructions on how to use pastebin.com.

    Thread Starter iAyo

    (@iayo)

    Thank you Jan,

    I failed to mention that im using wordpress v3.3.2, i hope this will help in solving the issue.

    Thread Starter iAyo

    (@iayo)

    Hi,
    figured out what was wrong, the scripts and styles were added below the output of functions i attached to the wp_script_styles() hook. I now need to figure out why the $priority isn’t making them print immediately after wp_head().

    I thank you all for your help…..

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘wp_enqueue_script issues’ is closed to new replies.