dots Created with Sketch.
Yogesh Chauhan's Blog

Debugging in WordPress Part 3: SCRIPT_DEBUG and SAVEQUERIES

in WordPress on January 24, 2021

This article was published on WordPress.org

SCRIPT_DEBUG

SCRIPT_DEBUG is a related constant that will force WordPress to use the “dev” versions of core CSS and JavaScript files rather than the minified versions that are normally loaded.

This is useful when you are testing modifications to any built-in .js or .css files. Default is false.


define( 'SCRIPT_DEBUG', true );

SAVEQUERIES

The SAVEQUERIES definition saves the database queries to an array and that array can be displayed to help analyze those queries.

The constant defined as true causes each query to be saved, how long that query took to execute, and what function called it.


define( 'SAVEQUERIES', true );

The array is stored in the global $wpdb->queries.

This will have a performance impact on your site, so make sure to turn this off when you aren’t debugging.

Example wp-config.php for Debugging

The following code, inserted in your wp-config.php file, will log all errors, notices, and warnings to a file called debug.log in the wp-content directory.

It will also hide the errors so they do not interrupt page generation.


// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( 'SCRIPT_DEBUG', true );

NOTE: You must insert this BEFORE /* That’s all, stop editing! Happy blogging. */ in the wp-config.php file.

amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jul 22 Is there a CSS parent selector? #Jul 22 Difference between :where and :is in CSS #Jul 22 Does :is() pseudo selector hint at CSS preprocessing in the future? #Jul 22 Control Scrolling with CSS Scroll Snap #Jul 21 Control rendering using CSS content-visibility property #Jul 21 How to use @supports rule in CSS?
You might also like these
How to add a Bar Chart in Angular App?AngularWordPress: How to loop through ACF group fields?WordPressIntroduction to components and templates Part 4: Pipes and DirectivesAngularKilling A Project Part 2: Who should make the decision to kill a project?MiscellaneousThe actual difference between indexOf() and search() in JavaScriptJavaScriptHow to draw an SVG path on scroll using JavaScript?JavaScript