Best Way to Load CSS Minify On WordPress Theme and Load RTL CSS Minify
Best Way to Load CSS Minify On WordPress Theme and Load RTL CSS Minify

awproject.net – Minify the css file or javascript file are best way to improve performance of any web site no exception web site based WordPress CMS. basicly this method use same code of load WordPress CSS on previous article and sequel if that article.

Read : How to load CSS on WordPress theme. Main CSS and RTL CSS

Follow this step to load minify CSS on your WordPress theme

1. On your functions.php file of your theme add code below

if( ! function_exists( 'themeslug_load_scripts' ) ):
function themeslug_load_scripts() {
  wp_enqueue_style( 'themeslug-style', get_template_directory_uri() .'/style.min.css', array(), array(), '1.0' );
}
endif;
add_action( 'wp_enqueue_scripts', 'themeslug_load_scripts' );

2. Duplicate style.css and rename it to style.min.css. On this step inside style.min.css have same value style.css

3. Copy all css code on style.css and go to cssminifier.com for compress css file and copy the result paste on style.min.css.

4. Add additional script to support of RTL style

wp_style_add_data( 'themeslug-style', 'rtl', 'replace' );
wp_style_add_data( 'themeslug-style', 'suffix', '.min');

So, full code look like below

if( ! function_exists( 'themeslug_load_scripts' ) ):
function themeslug_load_scripts() {
  wp_enqueue_style( 'themeslug-style', get_template_directory_uri() .'/style.min.css', array(), array(), '1.0' );
  wp_style_add_data( 'themeslug-style', 'rtl', 'replace' );
  wp_style_add_data( 'themeslug-style', 'suffix', '.min');
}
endif;
add_action( 'wp_enqueue_scripts', 'themeslug_load_scripts' );

5. Like on step 2 duplicate style-rtl.css and rename style-rtl.min.css and compress file on cssminifier.com

6. Make sure using same style id : themeslug-style

Thanks for reading :mrgreen: leave comment if any question …

widhy980

Blogger, Web Developer & Traveler

Hi, I am from Indonesia, and i have more interest about website development. i have good skill on Codeigniter, Wordpress, HTML x CSS and Bootstrap. have a business? please contact me ... :D

You Might Also Like

Leave a Reply

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