Force Immediate CSS changes to be seen on the Frontend

I found code to immediately show CSS site changes on the frontend.

I have many times become very frustrated when I adjusted some CSS and could not immediately see the changes on the frontend. I have come across a technique that would skip the cache system and show the CSS changes right away.

Add the following to your functions.php file or a code snippet plugin:

// Version CSS file in a theme
 wp_enqueue_style( 'theme-styles', get_stylesheet_directory_uri() . '/style.css', array(), filemtime( get_stylesheet_directory() . '/style.css' ) );

// Version JS file in a theme
 wp_enqueue_script( 'theme-scripts', get_stylesheet_directory_uri() . '/js/scripts.js', array(), filemtime( get_stylesheet_directory() . '/js/scripts.js' ) );

For more information check this link: kellenmace.com/force-css-changes-to-go-live-immediately

Share the article:

Leave a Reply

Your email address will not be published. Required fields are marked *