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 ?

3

There are 3 best solutions below

0
On BEST ANSWER

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);
0
On

Hook to the wp_print_scripts action, with a late priority (100) so that it is after the script was enqueued.

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

This is not js, but php code. It should be added to functions.php of your theme.