First of all, to resolve the javascript conflict I’ve set up a simple tl_custom.js
under my theme js/
folder, with the following code
jQuery(document).ready(function($) {
// Remove handler set by themes/Divi/js/custom.js at line 2642
$( 'a[href*=#]:not([href=#])' ).off();
});
Then I add the script with the following code in functions.php
function tl_custom_scripts() {
if ( ! is_admin() ) {
$scriptsrc = get_stylesheet_directory_uri() . '/js/';
wp_register_script( 'tl_custom', $scriptsrc . 'tl_custom.js', '', '', true );
wp_enqueue_script( 'tl_custom' );
}
}
add_action( 'wp_enqueue_scripts', 'tl_custom_scripts', 20 );
The main problem is that the parent theme register custom.js
in the footer, so I had to set the wp_register_script last parameter to true
and then set add_action priority to 20.