Exemplo n.º 1
0
/**
 * Minifier du HTML
 * 
 * @param string $flux  HTML à compresser
 * @return string       HTML compressé
 */
function minifier_html($flux)
{
    // si pas de contenu ni de balise html, ne rien faire
    if (!strlen($flux) or strpos($flux, "<") === FALSE) {
        return $flux;
    }
    static $options = null;
    if (is_null($options)) {
        $options = array();
        if ($GLOBALS['meta']['auto_compress_css'] == 'oui') {
            $options['cssMinifier'] = 'minifier_css';
        }
        if ($GLOBALS['meta']['auto_compress_js'] == 'oui') {
            $options['jsMinifier'] = 'minifier_js';
        }
        include_spip('lib/minify_html/class.minify_html');
    }
    return Minify_HTML_SPIP::minify($flux, $options);
}
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  *
  * @param string $html
  *     HTML à minifier
  * @param array $options
  *     Tableau d'option avec les index possibles 
  *     - 'cssMinifier' : (optional) callback function to process content of STYLE
  *        elements.
  *     - 'jsMinifier' : (optional) callback function to process content of SCRIPT
  *        elements. Note: the type attribute is ignored.
  *     - 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If
  *        unset, minify will sniff for an XHTML doctype.
  * @return string
  *     HTML minifié
  **/
 public static function minify($html, $options = array())
 {
     $min = new Minify_HTML_SPIP($html, $options);
     return $min->process();
 }