Okay
  Public Ticket #2586111
Custom init.js
Closed

Comments

  • Margrethe started the conversation

    I have tried to deregister Salient init.js and use my own init.js, but nothing changes and the parent theme init.js is still loaded. What am I doing wrong?

    Added this to my child themes function file:

    add_action('wp_enqueue_scripts', 'unhook_parent_script',20 );
    function unhook_parent_script() {
    wp_deregister_script('nectarFrontend', get_template_directory_uri() . '/js/init.js', array('jquery', 'superfish'), $nectar_theme_version, TRUE);
    wp_register_script('nectarFrontend', get_stylesheet_directory_uri() . '/js/init.js', array('jquery', 'superfish'), $nectar_theme_version, TRUE);
    }


  •  1,075
    ThemeNectar replied

    Hey Margrethe, the snippet you posted was close, but it needs to be modified a littlesmile.png

    add_action('wp_enqueue_scripts', 'unhook_parent_script',20 );
    function unhook_parent_script() {
        $nectar_theme_version = nectar_get_theme_version();
        wp_deregister_script('nectar-frontend');
        wp_register_script('nectar-frontend', get_stylesheet_directory_uri() . '/js/init.js', array('jquery', 'superfish'), $nectar_theme_version, TRUE);
    }
    

    Cheers