V
V
vvvadimos2016-02-17 18:41:38
PHP
vvvadimos, 2016-02-17 18:41:38

How to properly disable plugin js files?

Let's say on a certain page I want the js of the plugin not to be loaded on the page
, I write:

function exclude_js() {
  if( is_single() ){
    wp_deregister_script('crayon_js');
  }
}
add_action('wp_print_scripts', 'exclude_js', 100);

done, the js of this plugin will not be connected in the posts. but if you enable WP_DEBUG
, it gives "Notice: Undefined index: crayon_js in ... "

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mr Crabbz, 2016-02-17
@vvvadimos

In addition to wp_deregister_script, you also need to do wp_dequeue_script.

S
Silm, 2016-02-17
@Silm

I don’t know how in WP, but usually they include the necessary files. And do not turn off unnecessary ones .

E
Evansive, 2014-11-01
@Evansive

The task of the typesetter is to lay out the skeleton. Think for yourself what can be implemented on the client side, that is - your task. Sorting, for example, can be implemented using JS, but again, depending on what the server gave us. Comments are up to the programmer. Writing, reading and storing data is the task of the back-end developer. Rendering comments from the client side is up to you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question