The 3rd parameter of wp_enqueue_script()
, called $deps
, will help you to solve this. You just need to know the handle with which owl carousel was enqueued. Assuming it is owlcarousel
, you’d change your code to this
wp_enqueue_script(
'custom-script',
get_stylesheet_directory_uri() . '/custom-script.js',
array('jquery','ultrabootstrap-bootstrap','ultrabootstrap-scripts','owlcarousel')
// added this new dependancy -----------------------------------------^
);
This way, WordPress will do the magic under the hood for you. If you don’t know the handle, just check the source code of the plugin which enqueues owl carousel.