javascriptjquerywordpresschild-theming

Dequeue script from wordpress theme using a child theme return "Uncaught ReferenceError: add_action is not defined" error


i'm trying to remove a script from a wordpress theme using a child-theme. After several research on stack overflow, google and youtube, I'm still unable to find an answer to my problem.

The script always return "Uncaught ReferenceError: add_action is not defined" in the console

here's the .js that remove the file :

 function dequeue_scripts(){ 

      wp_dequeue_script("refrakt-stickymenu"); //disable sticky menu
 }

 add_action("wp_print_scripts","dequeue_scripts", 0);

What am I doing wrong ?


Solution

  • It is not js script, this is php code. You should add this to functions.php of your active theme.

    function dequeue_scripts(){ 
    
      wp_dequeue_script("refrakt-stickymenu"); //disable sticky menu
    }
    
    add_action("wp_print_scripts","dequeue_scripts", 0);