Dequeue scripts on pages not using player
-
Hi. I am trying to remove the mb audioplayer assets from pages that don’t use it to improve page performance. I am trying to using “Asset Cleanup” plugin to do that but it breaks the page with JS Console errors.
The page link added to this Q is for a page that is broken, then rest of the site loads all MBA assets as normal.
When I stop the mba assets loading on a page, this causes JS errors and my sticky header/search box stops working.
The assets I stop loading are:
map_overwrite_default_me /wp-content/plugins/wp-miniaudioplayer/js/map_overwrite_default_me.js mb.miniAudioPlayer /wp-content/plugins/wp-miniaudioplayer/js/jquery.mb.miniAudioPlayer.min.js mb.miniAudioPlayer.css /wp-content/plugins/wp-miniaudioplayer/css/miniplayer.css
This causes the following Console errors in Firefox:
ReferenceError: replaceDefault is not defined harp-making:730:32 <anonymous> https://dev.handsonharps.com/harp-making/:730 TypeError: jQuery(...).not(...).not(...).mb_miniPlayer is not a function harp-making:722:102 initializeMiniAudioPlayer https://dev.handsonharps.com/harp-making/:722 <anonymous> https://dev.handsonharps.com/harp-making/:732 i https://dev.handsonharps.com/wp-content/cache/asset-cleanup/js/logged-in/head-f1b076388454c99e737f8a0910e7ed0362068d07-1.js:3 fireWith https://dev.handsonharps.com/wp-content/cache/asset-cleanup/js/logged-in/head-f1b076388454c99e737f8a0910e7ed0362068d07-1.js:3 ready https://dev.handsonharps.com/wp-content/cache/asset-cleanup/js/logged-in/head-f1b076388454c99e737f8a0910e7ed0362068d07-1.js:3 J https://dev.handsonharps.com/wp-content/cache/asset-cleanup/js/logged-in/head-f1b076388454c99e737f8a0910e7ed0362068d07-1.js:3
I have tried to dequeue the assets using the following in child theme functions.php but seems not to do anything.
add_action('wp_print_scripts', function () { wp_dequeue_script( 'map_overwrite_default_me ' ); wp_dequeue_script( 'mb.miniAudioPlayer' ); }); add_action( 'wp_enqueue_scripts', 'xxxxxx', 99 ); function xxxxxx() { wp_dequeue_script( 'map_overwrite_default_me ' ); wp_dequeue_script( 'mb.miniAudioPlayer' ); }
I have unloaded several other plugins such as the Revolution Slider on home page without a hitch.
Any help with this much appreciated.
P.S. I did make a donation when I started using this plugin a year or so ago as I was so impressed with it ??
-Colin
WP 5.3.2
MBA 1.9.3
Asset Cleanup : 1.3.5.7
Total Theme: 4.9.6The page I need help with: [log in to see the link]
- The topic ‘Dequeue scripts on pages not using player’ is closed to new replies.