Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created August 29, 2012 15:53
Show Gist options
  • Select an option

  • Save wpsmith/3514759 to your computer and use it in GitHub Desktop.

Select an option

Save wpsmith/3514759 to your computer and use it in GitHub Desktop.
Enqueues Appropriate Scripts when needed based on Debugging.
<?php
add_action( 'wp_enqueue_scripts', 'wps_child_script' );
/**
* Enqueues Appropriate Scripts when needed based on Debugging.
* Assumes that the normal *.js is the minified version & *-dev.js is beautified version.
*
* @uses wp_enqueue_script() WP adds JS to page safely.
* @uses WP_DEBUG Constant: Triggers "debug" mode throughout WordPress
* @uses WP_SCRIPT_DEBUG Constant: Forces WordPress to use the "dev" versions of core CSS and Javascript files
* @uses CHILD_URL Constant: Genesis Child URL
*/
function wps_child_script() {
$suffix = ( WP_DEBUG || WP_SCRIPT_DEBUG ) ? '-dev.js' : '.js';
wp_enqueue_script( 'my-awesome-js-1', CHILD_URL . '/js/myawesomeness1' . $suffix, array( 'jquery' ) , '1.0.0', true );
wp_enqueue_script( 'my-awesome-js-2', CHILD_URL . '/js/myawesomeness2' . $suffix, array( 'jquery' ) , '1.0.0', true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment