Support » Plugins » Hacks » How to queue minified files in production, but not development

  • I’m starting to integrate gulp with my WP site for tasks like minifying js and compiling SASS. I’m not using the minified output files in development, but want to use for production.

    Right now, I’m using in functions.php the wp_enqueue_script function to queue all my .js files. However, once I integrate minified, concatenated .js files in production, how do I do this within WP so that in development I’m queueing the non-minified files, but in production, I’m using the minified files?

    Is it a matter of detecting the environment I’m in in functions.php and queueing the files based on that? Or is there another way–maybe more elegant?– to do this?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You may as well use the SCRIPT_DEBUG constant that WP uses for the same purpose.

    Much like WP_DEBUG, you define it as true in wp-config.php for development. When time comes to launch the site, change the definition to false. Naturally, you can change it back anytime if the need arises.

    Thread Starter the_enn

    (@the_enn)

    Perfect, thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to queue minified files in production, but not development’ is closed to new replies.