<?php // setup the URL, the CSS and the form data $url = 'https://cssminifier.com/raw'; $css = file_get_contents('./public/s/css/style.css'); $data = array( 'input' => $css, ); // init the request, set some info, send it and finally close it $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $minified = curl_exec($ch); curl_close($ch); // output the $minified echo $minified; ?>
Also, Toni Almeida has made a PHP library to easily talk to CSS Minifier : https://github.com/promatik/PHP-JS-CSS-Minifier.
Click on the language of your choice:
I'd love to add more examples in your favourite programming language, so feel free to send them my way. Email andychilton at that gmail place in the sky or tweet to me @andychilton.