0

Hello I am trying to dequeue the script "jquery.favorite.js" found in my enqueue.php:

// WP_ENQUEUE_SCRIPTS
static function wp_enqueue_scripts_callback()
{
    global $javo_tso;

    $javo_register_scripts = Array(
        'oms.min.js'                                    => 'oms-same-position-script'
        , 'common.js'                                   => 'javo-common-script'
        , 'chosen.jquery.min.js'                        => 'jQuery-chosen-autocomplete'
        , 'jquery.javo.msg.js'                          => 'javoThemes-Message-Plugin'
        , 'jquery.parallax.min.js'                      => 'jQuery-Parallax'
        , 'jquery.favorite.js'                          => 'jQuery-javo-Favorites'
        , 'jquery_javo_search.js'                       => 'jQuery-javo-search'
        , 'jquery.flexslider-min.js'                    => 'jQuery-flex-Slider'
        , 'google.map.infobubble.js'                    => 'Google-Map-Info-Bubble'
        , 'pace.min.js'                                 => 'Pace-Script'
        , 'single-reviews-modernizr.custom.79639.js'    => 'single-reviews-modernizr.custom'
        , 'jquery.magnific-popup.js'                    => 'jquery-magnific-popup'
        , 'jquery.easing.min.js'                        => 'jQuery-Easing'
        , 'jquery.form.js'                              => 'jQuery-Ajax-form'
        , 'sns-link.js'                                 => 'sns-link'
        , 'jquery.raty.min.js'                          => 'jQuery-Rating'
        , 'jquery.spectrum.js'                          => 'jQuery-Spectrum'
        , 'jquery.parallax.min.js'                      => 'jQuery-parallax'
        , 'jquery.javo.mail.js'                         => 'jQuery-javo-Emailer'
        , 'bootstrap.hover.dropmenu.min.js'             => 'bootstrap-hover-dropdown'
        , '../bootstrap/bootstrap-select.js'            => 'bootstrap-select-script'
        , 'bootstrap-tagsinput.min.js'                  => 'bootstrap-tagsinput-min'
        , 'javo-footer.js'                              => 'javo-Footer-script'
        , 'bootstrap-markdown.js'                       => 'bootstrap-markdown'
        , 'bootstrap-markdown.fr.js'                    => 'bootstrap-markdown-fr'
        , 'jquery.quicksand.js'                         => 'jQuery-QuickSnad'
        , 'jquery.nouislider.min.js'                    => 'jQuery-nouiSlider'
        , 'okvideo.min.js'                              => 'okVideo-Plugin'
        , 'jquery.slight-submenu.min.js'                => 'slight-submenu.min-Plugin'
        , 'jquery.typehead.js'                          => 'jquery-type-header'
        , 'jasny-bootstrap.min.js'                      => 'jasny-bootstrap'
        , 'single-reviews-slider.js'                    => 'single-reviews-slider'
        , 'common-single-item.js'                       => 'common-single-item'
        , 'owl.carousel.min.js'                         => 'owl-carousel-script'
        , 'jquery.mixitup.min.js'                       => 'mixitup'
        , 'smoothscroll.js'                             => 'smoothscroll'
        , 'javo-single-property.js'                     => 'javo-single-property'

        /* Widget */
        , 'javo-wg-featured-scripts.js'                 => 'javo-wg-featured-scripts'
    );

I added this into my functions.php:

add_action('wp_enqueue_scripts', 'my_remove_scripts');

function my_remove_scripts(){

    wp_dequeue_script( 'jquery.favorite' );
    }

However it is still being called.

I could just delete from enqueue.php but I'd rather do this through functions.php.

Thanks,

Joe

1 Answer 1

2

Just remove

, 'jquery.favorite.js' => 'jQuery-javo-Favorites' 

from the $javo_register_scripts Array

OR

function wpdocs_dequeue_script() {
    wp_dequeue_script( 'jQuery-javo-Favorites' );
}
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );
7
  • Thanks, it worked but is there a way to do this through functions.php? Commented Mar 19, 2015 at 17:25
  • Just added that aswell Commented Mar 19, 2015 at 17:26
  • 2
    Its worth noting the late priority of 100 so that it is after the script was enqueued Commented Mar 19, 2015 at 17:39
  • 1
    To properly remove scripts or styles, you have to dequeue and deregister :-) Commented Mar 19, 2015 at 18:27
  • If your not going to use the script at all, then it would be better to NEVER enqueue it in the first place. Commented Mar 19, 2015 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.