A
A
Arthur2015-11-15 16:41:35
PHP
Arthur, 2015-11-15 16:41:35

WordPress. How to selectively transfer JS plugins to the footer?

I use this function:

function footer_enqueue_scripts(){
   remove_action('wp_head','wp_print_scripts');
    remove_action('wp_head','wp_print_head_scripts',9);
    remove_action('wp_head','wp_enqueue_scripts',1);
    add_action('wp_footer','wp_print_scripts',5);
    add_action('wp_footer','wp_enqueue_scripts',5);
    add_action('wp_footer','wp_print_head_scripts',5);
}
add_action('after_setup_theme','footer_enqueue_scripts');

(designed to transfer all js to the footer, including plugins).
There is a problem - map builder, which requires connecting scripts in the header. How to deal with it? How to selectively leave the connection of scripts of some plugins in the head?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arthur, 2015-11-16
@r3st1k25

A great plugin - BWP Minify, has a special manager for determining where this or that script will be connected!

I
ixon, 2015-11-15
@ixon

You can load each plugin manually. You can load each plugin through yepnope, then there will be no difference at all in which place this or that plugin is connected.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question