Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Minify CSS
#1
This small plugin minifies one or more .css files to a common .min.css file.

The plugin is here: Minify CSS

When used in template header, you can automatically generate and refer a minimized version of your css file(s).

Usage
Two functions are provided:

Code:
return_minify_css(file1.css, [file2.css], ...)

returns the url of the resulting min.css file.

Code:
get_minify_css(file1.css, [file2.css], ...)

echoes the url of the resulting min.css file.

Both functions accept a variable number of css file paths as parameters.

The output file name is derived from the last file name parameter, supplemented with ".min.css".
This last file does not need to exist, so you can minify and combine 'css/style1.css' and 'css/style2.css' to generate 'css/common.min.css'
through calling
Code:
return_minify_css('css/style1.css', 'css/style2.css', 'css/common')

or in the template header
Code:
<link rel="stylesheet" href="<?php get_minify_css('css/style1.css', 'css/style2.css', 'css/common'); ?>" />

CSS file names can be:
* starting with http:// or https://, this can be a local or a remote css file (do not use remote url as last parameter, because the output file is derived from this, so make sure to add a local name parameter at last),
* starting with '/', this is file is relative to the local site root, or to the root path in GSROOTPATH
* otherwise, the file path is relative to the current theme.

This plugin can also be used in combination with the SCSS plugin :
         
Code:
<link rel="stylesheet" href="<?php get_minify_css(return_scss_css('css/main.scss')); ?>" />
Reply


Messages In This Thread
Minify CSS - by Knobbles - 2020-08-11, 20:29:49
RE: Minify CSS - by zekoolweb - 2020-08-31, 21:25:23
RE: Minify CSS - by krlllo - 2021-01-21, 01:27:19
RE: Minify CSS - by Knobbles - 2021-01-23, 23:46:51
RE: Minify CSS - by krlllo - 2021-02-17, 11:05:50



Users browsing this thread: 1 Guest(s)