$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Not all my scripts are enqueueing|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Not all my scripts are enqueueing

matteradmin6PV0评论

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
  • Is it not working? Or not being loaded at all? There's no script tag in the document at all? Also, wp_enqueue_scripts doesn't run in the admin, so ! is_admin() is redundant. – Jacob Peattie Commented Nov 16, 2018 at 12:09
  • 1 Try to change handler (common) name. – Pratik Patel Commented Nov 16, 2018 at 12:12
  • @PratikPatel That worked, didn't know it was a reserved word. is it? – Toni Michel Caubet Commented Nov 16, 2018 at 12:19
  • Yes may be its reserved word so thats why your script not load. – Pratik Patel Commented Nov 16, 2018 at 12:21
  • 1 common 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
 |  Show 1 more comment

1 Answer 1

Reset to default 2

Please try to change handler common name.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far