From both scripts, only 'custom.js' is loaded, not common.js
this is in my functions.php file:
<?php
function custom_scripts () {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_enqueue_script('common', get_bloginfo('template_directory') . '/js/common.js', array(), '1.0', true );
wp_enqueue_script('custom', get_bloginfo('template_directory') . '/js/custom.js', array(), '1.0.1', true );
wp_enqueue_script('common');
wp_enqueue_script('custom');
}
}
add_action("wp_enqueue_scripts", "custom_scripts");
?>
any idea whyy?
From both scripts, only 'custom.js' is loaded, not common.js
this is in my functions.php file:
<?php
function custom_scripts () {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_enqueue_script('common', get_bloginfo('template_directory') . '/js/common.js', array(), '1.0', true );
wp_enqueue_script('custom', get_bloginfo('template_directory') . '/js/custom.js', array(), '1.0.1', true );
wp_enqueue_script('common');
wp_enqueue_script('custom');
}
}
add_action("wp_enqueue_scripts", "custom_scripts");
?>
any idea whyy?
Share Improve this question asked Nov 16, 2018 at 12:05 Toni Michel CaubetToni Michel Caubet 6163 gold badges11 silver badges33 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 2Please try to change handler common
name.
wp_enqueue_scripts
doesn't run in the admin, so! is_admin()
is redundant. – Jacob Peattie Commented Nov 16, 2018 at 12:09common
is used from WordPress itself. Though I usually advise for deleting questions, I think you should not in this case and let @PratikPatel write up an answer. Feels like this could be important for future visitors (with my comment I wanted to provide the link for where WP uses this) – kero Commented Nov 16, 2018 at 12:38