String|bool|null $ver = false, bool $in_footer = false )Įxample: wp_register_script('myScript', get_template_directory_uri(). wp_enqueue_script( string $handle, string $src = '', array $deps = array(), If your script is depend on other script or scripts and must be inserted after those scripts to work correct, in wordpress you can use wp_enqueue_script() and pass array of dependencies(The 3rd parameter in wp_enqueue_script called $deps) that your script depends on, to this method. ![]() ![]() I would love to solve it with the 'wp_enqueue_scripts' tag. I found a solution: enqueue my scripts in my plugin like this: add_action( 'elementor/frontend/after_enqueue_scripts', 'ajax_chat_enqueue_scripts', 999999, 1) There's nothing about what the hell Elementor is doing to force their scripts to the bottom. I've Googled this topic but I end up with the same answers about how to get your script in the footer. I've tried increasing the priority for my enqueue scripts: add_action( 'wp_enqueue_scripts', 'ajax_chat_enqueue_scripts',999999,1) Īnd I'm enqueueing in the footer with 'footer=true' at the end: wp_enqueue_script( 'chat-post', plugins_url( '/chat-post.js', _FILE_ ), null, null, true ) īut still my script won't show up AFTER the script. It needs to load right before the end body tag. I've been trying to figure out what the Elementor (and Elementor Pro) plugins in Wordpress are doing to get their Scripts to load very last in the body, because my plugin Script needs to load AFTER those.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |