1

When I use the wp_register_script() and wp_enqueue_script() to load the jquery for the wordpress I got "no data received result with other information like this :

Unable to load the webpage because the server sent no data. Error code: ERR_EMPTY_RESPONSE
My code to load the jquery is

function theme_script(){
        wp_deregister_script( 'jquery' );

        wp_register_script('jquery',get_template_directory_uri().'/sliderengine/jquery.js');
        wp_enqueue_scripts('jquery');

        wp_register_script('amazingslider',get_template_directory_uri().'/sliderengine/amazingslider.js',array('jquery'));
        wp_enqueue_scripts('amazingslider');    

        wp_register_script('initslider-1',get_template_directory_uri().'/sliderengine/initslider-1.js',array('jquery'));
        wp_enqueue_scripts('initslider-1');
    }
    add_action('wp_enqueue_scripts','theme_script');
1

Your code is wrong. You are confusing wp_enqeue_script function and wp_enqueue_scripts action. It should be:

function theme_script(){
    wp_deregister_script( 'jquery' );

    wp_register_script('jquery',get_template_directory_uri().'/sliderengine/jquery.js');
    wp_enqueue_script('jquery');

    wp_register_script('amazingslider',get_template_directory_uri().'/sliderengine/amazingslider.js',array('jquery'));
    wp_enqueue_script('amazingslider');    

    wp_register_script('initslider-1',get_template_directory_uri().'/sliderengine/initslider-1.js',array('jquery'));
    wp_enqueue_script('initslider-1');
}
add_action('wp_enqueue_scripts','theme_script');
  • @cybmeta - Any reason why you don't just do this with one call to wp_enqueue_script? Unless the OP plans to enqueue the scripts from other files or deregister them, isn't it easier to not worry about first registering the scripts? – David Gard Feb 12 '15 at 9:57
  • I don't know the plans of the OP in that matter and I usually register the scripts and styles to make them available for easy use anywhere, so I just fix the errors in the code. I like this read. – cybmeta Feb 12 '15 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.