class-js.php

Minify JavaScript File Class

Source includes/minify/class-js.php1 min readPart of Performance Optimisation

includes/minify/class-js.php

Minify JavaScript File Class

Namespace: PerformanceOptimise\\Inc\\Minify · Lines: 189

Class JS

Class JS

Source: includes/minify/class-js.php, line 32

class JS

Tags: @package PerformanceOptimise\\Inc\\Minify · @since 1.0.0

Properties

PropertyVisibilityTypeDefaultLine
$file_pathprivatestring—39
$cache_dirprivatestring—47
$filesystemprivateobject—55
$cache_urlprivatestring—62

public __construct()

public function __construct(string $file_path, string $cache_dir)

JS constructor to initialize file path, cache directory, and filesystem.

ParameterTypeDefaultDescription
$file_pathstring—The path to the JavaScript file to minify.
$cache_dirstring—The directory to store the minified file.

Tags: @since 1.0.0

Source: includes/minify/class-js.php, line 72

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.

Tags: @since 1.0.0

Source: includes/minify/class-js.php, line 119

public get_cache_file_path()

public function get_cache_file_path(): string

Gets the cache file path for the minified JS.

Return: string — The full path to the cache file.

Tags: @since 1.0.0

Source: includes/minify/class-js.php, line 164

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.

ParameterTypeDefaultDescription
$jsstring—The minified JavaScript content.
$file_pathstring—The path where the file will be saved.

Tags: @since 1.0.0

Source: includes/minify/class-js.php, line 178