How to fix $.browser undefined error in WordPress

$.browser function has been deprecated from the latest jQuery version. It had the flags $.browser.webkit, $.browser.safari, $.browser.opera, $.browser.msie and $.browser.mozilla to detect respective browsers in previous versions. But now, if your site has code with these flags and your theme has the latest version of jQuery, then it will throw an error message sayings “undefined”. But do not worry, you can fix it.

From WordPress version 5.5, “jquery-migrate” library has been removed from WordPress core. Hence, you will get an error if your theme or any other plugins are trying to access any jQuery features that are deprecated. You can also install a plugin called Enable jQuery Migrate Helper, to include the jquery-migrate library in the latest version of WordPress.

How to fix $.browser error:

Normally this issue occurs in an older version of themes that are not updated. You have to enqueue jquery-migrate library in your theme to fix the issue.


You can check your theme for jquery script enqueue or any other script with jquery as a dependency and make sure that you add an additional dependency of jquery-migrate to fix the issue.

How to fix errors in admin section only :

// add jquery migrate only to the admin section
function wptips_add_jquery_migrate() {  
add_action('admin_enqueue_scripts', 'wptips_add_jquery_migrate'); 

If you still have any questions, please ask me in the comment section. I will be glad to help you out.

By Murali Kumar

Murali Kumar is a Full Stack Web Developer with over ten years of experience. He loves helping individuals & businesses with their WordPress based websites. He has worked with many small and medium-sized businesses from all over the world, helping them succeed with their website.

5 replies on “How to fix $.browser undefined error in WordPress”

You can use only the first snippet. Insert the snippet in functions.php file of your currently active theme.

Feel free to let me know, if you still have any questions. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *