I have a plugin on my Wordpress that I want to block when a user is on mobile. In my functions.php I added the line:
if (wp_is_mobile())
{
wp_dequeue_script('flare');
wp_deregister_script('flare');
}
Unfortunately, this made the script not load for both mobile and desktop users. So I need to figure out a way to make this script unload if they are on mobile.
I used a similar function inside my post-template, for adding regular share buttons at the bottom of the post if they were on mobile - but this also didn't work. It added the share buttons for both mobile and desktop users.
Any help would be greatly appreciated!
I think Script
dequeuing
calls should be added to thewp_print_scripts
action hook.Scripts are normally enqueued on the
wp_enqueue_script
hook, which happens early in thewp_head
process. Thewp_print_scripts
hook happens right before scripts are printed. So I think you should be doing as follows :You can also add the action hook to
wp_enqueue_scripts
So another method will be
Hope this helps you :-)
Try this...