Frontend\Core\Engine\Header::minifyJS PHP Méthode

minifyJS() private méthode

Minify a javascript-file
private minifyJS ( string $file ) : string
$file string The file to be minified.
Résultat string
    private function minifyJS($file)
    {
        $fileName = md5($file) . '.js';
        $finalURL = FRONTEND_CACHE_URL . '/MinifiedJs/' . $fileName;
        $finalPath = FRONTEND_CACHE_PATH . '/MinifiedJs/' . $fileName;
        // check that file does not yet exist or has been updated already
        $filesystem = new Filesystem();
        if (!$filesystem->exists($finalPath) || filemtime(PATH_WWW . $file) > filemtime($finalPath)) {
            // create directory if it does not exist
            if (!$filesystem->exists(dirname($finalPath))) {
                $filesystem->mkdir(dirname($finalPath));
            }
            // minify the file
            $js = new Minify\JS(PATH_WWW . $file);
            $js->minify($finalPath);
        }
        return $finalURL;
    }