includes/minify/class-js.php
Minify JavaScript File Class
Class JS
Class JS
class JSProperties
| Property | Visibility | Type | Default | Line |
|---|---|---|---|---|
$file_path | private | string | — | 39 |
$cache_dir | private | string | — | 47 |
$filesystem | private | object | — | 55 |
$cache_url | private | string | — | 62 |
public __construct()
public function __construct(string $file_path, string $cache_dir)JS constructor to initialize file path, cache directory, and filesystem. Parameter Type Default Description $file_pathstring— The path to the JavaScript file to minify. $cache_dirstring— The directory to store the minified file.
public minify()
public function minify()Minifies the JavaScript file and saves it to the cache directory.
Return: string — The URL of the minified JavaScript file or empty string if minification fails.
public get_cache_file_path()
public function get_cache_file_path(): stringGets the cache file path for the minified JS.
Return: string — The full path to the cache file.
private save_min_file()
private function save_min_file($js, $file_path)Saves the minified JavaScript content to the specified file path, including a gzipped version of the file. Parameter Type Default Description $jsstring— The minified JavaScript content. $file_pathstring— The path where the file will be saved.