Minify CSS - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Plugins (http://get-simple.info/forums/forumdisplay.php?fid=13) +--- Thread: Minify CSS (/showthread.php?tid=14856) |
Minify CSS - Knobbles - 2020-08-11 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')); ?>" /> RE: Minify CSS - zekoolweb - 2020-08-31 thank you for the sharing, i will try this for sure, as load speed is crucial these days. Best from France. RE: Minify CSS - krlllo - 2021-01-21 I tried to use it and once I activate the plugin, it gives an error and breaks the entire website. Is it necessary to modify gsconfig file? It might be a dummy question, but I am not sure about the usage of the two functions, are both functions necessary? Also, if not in the header, where else do I put the functions? Whatever I try, I can't get it to work. RE: Minify CSS - Knobbles - 2021-01-23 Hello, when exactly does the problem occur? After activating it, or when using one of its functions? You say it gives an error, what does the error message say? And which PHP version is used? I found that you were/are testing GetSimple 3.4. Do you also use it here? I do not know whether this plugin is compatible, because it was made and is currently in use with GetSimple 3.3.16. *** No need to modify the gsconfig file. Both functions do generally the same, they minify the css file(s) and provide the URL path of the minified version. Which of the functions will be needed depends on what you want to achieve. As usual with GetSimple, the get... function Code: get_minify_css() while the return... function Code: return_minify_css() So if you just want to minify your css file and then refer the minified css in the HTML header of your template, you just insert there Code: <link rel="stylesheet" href="<?php get_minify_css('css/mystyle.css'); ?>" /> I feel this is the most common usage. But perhaps you wish to minify and after this do something more with the minified file, you might want to call it from functions.php. Then you will probably use Code: return_minify_css('css/mystyle.css'); I hope usage is more clear now. RE: Minify CSS - krlllo - 2021-02-17 (2021-01-23, 23:46:51)Knobbles Wrote: Hello, Now it works. I was inserting a / before the path. Like this ('/css/mystyle.css'); Thank you for the promptly response. |