'Javascript doesn't load on wordpress pages added with wp_footer webhook

Hello and thank you for your time.

I'm building wordpress plugin, which should add some javascript code on every page of wordpress site.

So i decided to register script and add it to page with wp_footer hook. But it doesn't loaded on pages.

I added var_dump() to check if is it registed and on every page, i got " bool(true)" on all pages. So, hook should work, as i saw true, but the script doesn't loaded.

Can someone tell me, where i made a mistake?


// code inside my lieman.php main plugin file
function liemanAppend() {
    wp_register_script('lieman_code', 'https://lieman.ru/static/js/jquery.validate.min.js');
    wp_enqueue_script('lieman_code');

    var_dump(wp_script_is('lieman_code', 'enqueued'));
}

add_action('wp_footer', 'liemanAppend', 100000);



Solution 1:[1]

your hooking into a hook too late on, try the below :)


add_action('wp_enqueue_scripts', 'liemanAppend');

function liemanAppend() {
    wp_register_script(
        'lieman_code', 
        'https://lieman.ru/static/js/jquery.validate.min.js',
        array(),
        1,
        true
    );
    wp_enqueue_script('lieman_code');

    var_dump(wp_script_is('lieman_code', 'enqueued'));
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Barrie Dawson