Title: Enqueue minified css files
Last modified: August 31, 2016

---

# Enqueue minified css files

 *  [petroglyphic](https://wordpress.org/support/users/petroglyphic/)
 * (@petroglyphic)
 * [10 years ago](https://wordpress.org/support/topic/enqueue-minified-css-files/)
 * I have read that if your theme includes both style.css and style.min.css, WordPress
   will automatically load style.min.css and fall back to style.css if the minified
   version is missing. I am enqueuing secondary css files using enqueue_scripts 
   and want it to work the same way – load minified file if present and non-minified
   file as fallback – but can’t figure out how to do it. If I enqueue “style2.css”
   and “style2.min.css” is present in the same location “style2.css” is still loaded.
 * If there is a more appropriate forum somebody please let me know!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [10 years ago](https://wordpress.org/support/topic/enqueue-minified-css-files/#post-7445358)
 * The files in question would be get_stylesheet_directory().’/style2.css’ or ‘/
   style2.min.css’, so you can use that to test their existence and based on the
   result of that, decide which to enqueue line you would any other CSS file.
 * See [https://codex.wordpress.org/Function_Reference/get_stylesheet_directory](https://codex.wordpress.org/Function_Reference/get_stylesheet_directory)
 *  Thread Starter [petroglyphic](https://wordpress.org/support/users/petroglyphic/)
 * (@petroglyphic)
 * [10 years ago](https://wordpress.org/support/topic/enqueue-minified-css-files/#post-7445368)
 * Thanks for the response.
 * I know which files are there. What I am trying to figure out is: is there a way
   to enqueue so that the .min.css version of the stylesheet is called _if it exists
   in the specified location_ but automatically fall back to the plain .css version
   if there is no minified version there.
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [10 years ago](https://wordpress.org/support/topic/enqueue-minified-css-files/#post-7445380)
 * no, it’s up to you to code that if that’s what you want.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Enqueue minified css files’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/enqueue-minified-css-files/#post-7445380)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
