Dequeuing Scropts
-
Hi folks,
I normally use plugins to add in custom JS or CSS, or use a theme’s inbuilt capabilities. However this time I tried to add a custom JS script with the WordPress enqueue function:
function ae_add_custom_scripts_function() { wp_enqueue_script( 'js-file', get_template_directory_uri() . '/js/ae-bb-custom-jquery.js'); } add_action('wp_enqueue_scripts','ae_add_custom_scripts_function');
Ref: https://www.collectiveray.com/add-javascript-to-wordpress
The script only has one function which I tested previously and it worked in a plugin that adds JS/CSS to each page of the site. That plugin was disabled and removed before I tried enquing.
However, I must have added this to the wrong place in functions.php as it “breaks” my site and causes the page referenced to fire the function as soon as certain pages are loaded (2 of three pages in the artists menu).
I tried removing the script, even deleting it from the server and that didn’t work! Then I realised I had to dequeue the script. I tried the technique here:
https://pupungbp.com/how-to-remove-dequeue-deregister-script-on-wordpress/
function deregister_ae_add_custom_scripts_function() { wp_dequeue_script( 'ae_add_custom_scripts_function' ); wp_deregister_script( 'ae_add_custom_scripts_function' ); } add_action( 'wp_print_scripts', 'deregister_ae_add_custom_scripts_function' );
However, this isn’t working. Can anyone point me in the right direction here?
The page I need help with: [log in to see the link]
- The topic ‘Dequeuing Scropts’ is closed to new replies.