Skip to content

Instantly share code, notes, and snippets.

@mathetos
Last active March 12, 2019 14:10
Show Gist options
  • Save mathetos/06c37f92b4972bcfda89785fed89b8f1 to your computer and use it in GitHub Desktop.
Save mathetos/06c37f92b4972bcfda89785fed89b8f1 to your computer and use it in GitHub Desktop.
Function for conditionally enqueing minified or un-minified scripts based on WP_DEBUG
<?php
add_action( 'wp_enqueue_scripts', 'debug_theme_enqueue_styles' );
function debug_theme_enqueue_styles() {
if (WP_DEBUG == true) :
$random = mt_rand();
wp_enqueue_style( 'main-css-unminified', get_template_directory_uri() . '/assets/styles/build/main.css', '', $random );
else :
wp_enqueue_style( 'main-css-minified', get_template_directory_uri() . '/main.min.css', '', MY_THEME_VERSION );
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment