没有不值得去解决的问题,也没有不值得去学习的技术!

WordPress Dashboard Error Troubleshooting: From jQuery Conflicts to Baidu Analytics Warnings

Recently, while inspecting my WordPress website, I noticed several unsettling red error messages in the browser developer tools console:

作者:

在

While maintaining WordPress websites, we often encounter console errors. These errors can sometimes look intimidating, but not all of them will cause a site to crash. This article will share a real-world case, demonstrating how to troubleshoot and resolve these errors step by step to get your site back to a healthy state.

1. First Signs: “Red Text” in the Console

Recently, while inspecting my WordPress website, I noticed several unsettling red error messages in the browser developer tools console:

  1. Uncaught TypeError: Cannot read properties of undefined (reading 'msie')
  2. Uncaught TypeError: jQuery(...).fancybox is not a function
  3. [Violation] Permissions policy violation: unload is not allowed in this document.
Recently, while inspecting my WordPress website, I noticed several unsettling red error messages in the browser developer tools console:

Although these error messages look complex, careful analysis allows us to find the root cause of the problem.

2. Problem Analysis: Sources and Causes of the Errors

2.1 The jQuery and Fancybox Compatibility Disaster

The first two errors, Cannot read properties of undefined (reading 'msie') and jQuery(...).fancybox is not a function, both point to a common source: a plugin named “Light – Responsive LightBox”.

  • Cause of the error: This plugin relies on a jQuery library called Fancybox. However, the version of this library is very outdated, and it attempts to access a property that was removed in newer versions of jQuery, $.browser.msie (used to detect the Internet Explorer browser). Because this property is undefined in the current environment, the code throws an TypeError when trying to read its properties. This error prevents the Fancybox plugin from initializing correctly, so when the fancybox method is subsequently called, the browser reports that “it is not a function”.
  • Direct impact: All images or galleries on the site that rely on this lightbox plugin can no longer display the zoom effect properly, significantly degrading the user experience.

2.2 The Baidu Tongji “Permission” Warning

The third error, [Violation] Permissions policy violation: unload is not allowed in this document., comes from another common service: Baidu Tongji.

  • Cause of the error: The Baidu Tongji tracking script hm.js attempts to use the browser’s unload event to send final statistics when the user leaves the page. However, to improve performance and user experience, modern browsers now disable the unload event by default. As a result, the browser throws this “Permissions policy violation” warning.
  • Direct impact: This warning will not cause website functionality to fail, nor will it affect Baidu Tongji’s core data collection. It is merely a “notification” indicating that a third-party script is using a method deprecated by modern browsers.

3. Solutions: Addressing the Root Cause

We adopted different strategies for these two issues of different natures.

3.1 Resolving the jQuery Conflict: Removing the Outdated Plugin

For core functional errors caused by a plugin, the most direct and effective solution is to remove the problematic plugin.

  1. Deactivate and delete the plugin: Log in to the WordPress dashboard, go to the “Plugins” page, find the “Light – Responsive LightBox” plugin, and click “Delete”.
  2. Clear the cache: After deleting the plugin, be sure to clear the website’s cache (including WordPress caching plugins, server cache, and browser cache) to ensure the new state takes effect.

3.2 Ignoring the Baidu Tongji Warning

As for the Baidu Tongji unload warning, we chose to temporarily ignore it.

  • Reason: This error originates from Baidu’s official script, not from our website configuration. It does not affect the normal operation of the website, nor will it cause data loss. Waiting for Baidu to officially update its tracking code is the best choice, requiring no manual intervention on our part.

4. Result Verification: Errors Gone, Website Restored to Health

After deleting the plugin and clearing the cache, I refreshed the page again and checked the console. The results were satisfactory!

After deleting the plugin and clearing the cache, I refreshed the page again and checked the console. The results were satisfactory!


As shown in the image above, the two jQuery errors that previously caused functionality to fail have completely disappeared, leaving only the harmless Baidu Tongji warning.

5. Summary and Recommendations

Through this experience, I have summarized the following lessons, hoping they will help everyone better maintain their WordPress websites:

  1. Prioritize functional errors: When errors appear in the console, first focus on those that cause website functionality to fail (such as TypeError), and prioritize resolving them.
  2. Beware of outdated plugins: Many compatibility errors stem from using outdated plugins or themes. Regularly checking and updating them is key to keeping a website healthy.
  3. Leverage native WordPress features: WordPress version 5.4 and above has built-in lightbox functionality for the Gallery block, allowing you to achieve image zoom effects without additional plugins, which avoids many compatibility issues.
  4. Understand third-party script warnings: For warnings from third-party services (like Baidu Tongji), unless they severely impact website functionality, you can temporarily ignore them and wait for the service provider to update their code.
  5. Check the console regularly: As a website administrator, regularly checking the console helps you discover and resolve potential issues promptly, keeping your website in optimal condition.

I hope this blog post helps you better understand and resolve console errors on your WordPress website! If you encounter other issues during your troubleshooting process, feel free to continue the discussion.

系列导航

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系