Script debugging in WP
The constant SCRIPT_DEBUG
is used to switch between minified and not minified versions of JavaScript files. But there’s more.
$file.js
Check if you’re using CONCATENATE_SCRIPTS
and COMPRESS_SCRIPTS
as well. Both are only used by core admin per default, but I use it in my themes as well to check which bag of scripts I’m loading. So watch out for it, set it and see the following example.
$extensionJS = (
( defined( 'COMPRESS_SCRIPTS' ) AND COMPRESS_SCRIPTS )
AND ( defined( 'CONCATENATE_SCRIPTS' ) AND CONCATENATE_SCRIPTS )
AND ! ( defined( 'SCRIPT_DEBUG' ) AND SCRIPT_DEBUG )
)
? '.min' : '';
$file.css
For completeness here’s the CSS example
$extensionCSS = ( defined( 'COMPRESS_CSS' ) AND COMPRESS_CSS ) ? '.min' : '';
You don’t need it…
Anyway, since we got Google Chrome Dev Tools, it’s pretty pointless to switch between compressed and uncompressed versions – as long as you didn’t use some minification process like “uglify” that’s renaming your variables to shorten them – as GC got “Pretty Print”. See the following example from the “Sources” tab (hit script link in “Elements” tab to open your file there). Image made with LiceCap.