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. It needs to load right before the end body tag.
<script type='text/javascript' src='https://example.com/wp-content/plugins/elementor/assets/lib/swiper/swiper.jquery.min.js?ver=4.4.3'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var elementorFrontendConfig = {"isEditMode":"","is_rtl":"","breakpoints":{"xs":0,"sm":480,"md":768,"lg":1025,"xl":1440,"xxl":1600},"urls":{"assets":"https:\/\/example.com\/wp-content\/plugins\/elementor\/assets\/"},"settings":{"page":[],"general":{"elementor_global_image_lightbox":"yes","elementor_enable_lightbox_in_editor":"yes"}},"post":{"id":406,"title":"Chat","excerpt":""}};
/* ]]> */
</script>
<script type='text/javascript' src='https://example.com/wp-content/plugins/elementor/assets/js/frontend.min.js?ver=2.2.1'></script>
</body>
</html>
I've tried increasing the priority for my enqueue scripts:
add_action( 'wp_enqueue_scripts', 'ajax_chat_enqueue_scripts',999999,1);
And 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 );
But still my script won't show up AFTER the frontend.min.js script.
I've Googled this topic but I end up with the same answers about how to get your script in the footer. There's nothing about what the hell Elementor is doing to force their scripts to the bottom.
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);
But that just seems like a hack. I would love to solve it with the 'wp_enqueue_scripts' tag.