You just need to enqueue your scripts before other script loads. You can do it by setting priority to 0 for your hook. For example, do the following:
add_filter( 'wp_enqueue_scripts', 'enqueue_your_scripts', 0 );
function enqueue_your_scripts() {
wp_enqueue_script( 'yourscript', 'URL', array( 'jquery' ) );
//URL of js in which your custom code exist.
}
You can set priority of loading script by change number in add_filter,
reference: add filter in wordpress
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.