Skip to content

Debug mode (WP_DEBUG, SAVEQUERIES, SCRIPT_DEBUG)

Debug mode is a set of switches in wp-config.php that help developers find errors. Three of them matter for speed:

  • WP_DEBUG turns on WordPress’s debug mode: PHP shows or logs every error, warning and notice.
  • SAVEQUERIES keeps every database query of a page in memory, with its duration and where it came from, so a developer can analyze it.
  • SCRIPT_DEBUG makes WordPress load the readable, unminified versions of its own stylesheets and scripts.

All three are off by default.

On a development copy, these switches are useful. On a live site, they cost something on every page. SAVEQUERIES is the expensive one: WordPress records each query while it builds the page, and pages with many queries need noticeably more time and memory. WP_DEBUG writes every notice somewhere, and depending on the other settings, error messages appear in the page itself, where visitors can see them, or pile up in a log file. SCRIPT_DEBUG makes WordPress’s own files larger.

WordPress’s own documentation advises against using the debug tools on live sites (source below).

WordPress: The switches are set in wp-config.php. The most common reason they’re on in a live site is that they were turned on to find a problem and never turned off again, or that a site was copied from a development copy as it was. Some hosting tools also turn them on for staging copies.

The Debug mode card is in System info, tab WordPress. It shows On or Off and names the switches that are on, such as “WP_DEBUG and SAVEQUERIES on”.

The rating depends on what kind of site WordPress says this is (its environment type, set with WP_ENVIRONMENT_TYPE; without a setting, WordPress treats a site as live):

  • Live or staging: red when SAVEQUERIES is on, with Slows down every page; yellow when WP_DEBUG is on, with Meant for development, not for a live site; green when all are off. SCRIPT_DEBUG alone has no color.
  • Local or development: no rating, with the note Not rated on a local site or Not rated on a development site.

When the card is red, the Dashboard also lists Debug mode is slowing down every page under Needs attention (see notifications). Under Changes, System info records when one of the switches is turned on or off.

Sources