Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

CSS Minifier Please report bugs on https://github.com/matthiasmullie/minify/issues

Author: Matthias Mullie <minify@mullie.eu>
Copyright: Copyright (c) 2012, Matthias Mullie. All rights reserved
License: MIT License
File Size: 814 lines (28 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: CSS  - X-Ref

CSS minifier

Please report bugs on https://github.com/matthiasmullie/minify/issues

setMaxImportSize($size)   X-Ref
Set the maximum size if files to be imported.

Files larger than this size (in kB) will not be imported into the CSS.
Importing files into the CSS as data-uri will save you some connections,
but we should only import relatively small decorative images so that our
CSS file doesn't get too bulky.

param: int $size Size in kB

setImportExtensions(array $extensions)   X-Ref
Set the type of extensions to be imported into the CSS (to save network
connections).
Keys of the array should be the file extensions & respective values
should be the data type.

param: string[] $extensions Array of file extensions

moveImportsToTop($content)   X-Ref
Move any import statements to the top.

return: string
param: string $content Nearly finished CSS content

combineImports($source, $content, $parents)   X-Ref
Combine CSS from import statements.

return: string
param: string   $source  The file to combine imports for
param: string   $content The CSS content to combine imports for
param: string[] $parents Parent paths, for circular reference checks

importFiles($source, $content)   X-Ref
Import files into the CSS, base64-ized.

return: string
param: string $source  The file to import files for
param: string $content The CSS content to import files for

execute($path = null, $parents = array()   X-Ref
Minify the data.
Perform CSS optimizations.

return: string The minified data
param: string[optional] $path    Path to write the data to
param: string[]         $parents Parent paths, for circular reference checks

move(ConverterInterface $converter, $content)   X-Ref
Moving a css file should update all relative urls.
Relative references (e.g. ../images/image.gif) in a certain css file,
will have to be updated when a file is being saved at another location
(e.g. ../../images/image.gif, if the new CSS file is 1 folder deeper).

return: string
param: ConverterInterface $converter Relative path converter
param: string             $content   The CSS content to update relative urls for

shortenColors($content)   X-Ref
Shorthand hex color codes.
#FF0000 -> #F00.

return: string
param: string $content The CSS content to shorten the hex color codes for

shortenFontWeights($content)   X-Ref
No description

shortenZeroes($content)   X-Ref
Shorthand 0 values to plain 0, instead of e.g. -0em.

return: string
param: string $content The CSS content to shorten the zero values for

stripEmptyTags($content)   X-Ref
Strip empty tags from source code.

return: string
param: string $content

stripComments()   X-Ref
Strip comments from source code.


stripWhitespace($content)   X-Ref
Strip whitespace.

return: string
param: string $content The CSS content to strip the whitespace for

extractMath()   X-Ref
Replace all occurrences of functions that may contain math, where
whitespace around operators needs to be preserved (e.g. calc, clamp)


extractCustomProperties()   X-Ref
Replace custom properties, whose values may be used in scenarios where
we wouldn't want them to be minified (e.g. inside calc)


canImportBySize($path)   X-Ref
No description

canImportByPath($path)   X-Ref
Check if file a file can be imported, going by the path.

return: bool
param: string $path

getPathConverter($source, $target)   X-Ref
Return a converter to update relative paths to be relative to the new
destination.

return: ConverterInterface
param: string $source
param: string $target