Handling script conflicts on admin pages

From Wordfence Documentation
Jump to: navigation, search

Overview

Some plugins or themes may cause conflicts with scripts, that can prevent some WordPress admin pages from working when both Wordfence and the other plugin (or theme) are enabled.

First, it is best to Open the JavaScript console and check for errors. This may show which plugin has caused the conflict.


Plugin conflicts from WordPress combining scripts

If one of the errors comes from "load-scripts.php", that is because WordPress combines multiple scripts into a single request so admin pages load a little more quickly, but since multiple scripts are loaded at once, an error in one script can affect the others. You can prevent this, so that each script will load individually by adding this line of code to your wp-config.php file:

define('CONCATENATE_SCRIPTS', false);


Be sure to add it before the line that says: /* That's all, stop editing! Happy blogging. */

This will either help show which script file is causing the conflict, or it may prevent the issue from happening. If you can find the cause of the conflict and fix it, you can remove this line from wp-config.php.


Plugins loading scripts on all admin pages

Most plugins shouldn't load scripts on other plugins' pages, but some do this unintentionally, or because they have features that work throughout all WordPress admin pages.

If you find a plugin that conflicts with Wordfence's admin pages, in most cases, the other plugin author should avoid loading their javascript files on pages where they are not required.


Caching and optimization plugins

If you use a plugin that "minifies" scripts or concatenates (combines) scripts, any script that is loaded can trigger a problem with other scripts. This type of feature is usually included in a caching or optimization plugin. You can temporarily disable the caching or optimization plugin and check if the problem still occurs. If it stops occurring, there are a few ways it can be fixed:

  • If your caching/optimization plugin allows you to exclude some scripts from optimization, you can add Wordfence's scripts to that list. This is the easiest solution, but may still leave conflicts between other plugins aside from Wordfence.
  • Temporarily disable other plugins, except for Wordfence and the caching/optimization plugin. Then, enable one additional plugin at a time until the problem occurs again. When you find which plugin causes the conflict, you can report the issue to the plugin author. Be sure to mention which caching/optimization plugin you are using too, since that can help them see what happened.
  • Temporarily switch themes and see if the problem still occurs. Some themes contain scripts and could cause the same problem.


Amazon CloudFront and other CDNs

Amazon CloudFront and some other CDNs have an option to treat files as the same, no matter what query string is included in the URL. WordPress, Wordfence, and other plugins use the "?ver=" query string to prevent caching when a new version is released, so if you use a CDN, it should be configured to treat URLs as different files if the query string is different, and "forward query strings to the origin" when they request files from your site. More details are available here.