Another “tip of the day”. I ran into this while testing some carousels and swiping banners. All needed the associated js scripts to be loaded lastly after the main page/ post content was already available. It seems that using wp_enqueue_script
last argument as true
will do the trick:
/** * global_js last true means that the script is embedded in the footer * * @return void */ function global_js() { wp_enqueue_script('js-global', get_theme_file_uri('/assets/js/global.js'), array('jquery'), '1.0', true); } add_action('wp_enqueue_scripts', 'global_js');
Hope you will find this useful. Cheers !
AP
Leave a Reply