class-asset-manager.php

Asset Manager functionality.

Source includes/Assets/class-asset-manager.php2 min readPart of Performance Optimisation

includes/Assets/class-asset-manager.php

Asset Manager functionality.

Namespace: PerformanceOptimise\\Inc · Lines: 405

Class Asset_Manager

Class Asset_Manager

Source: includes/Assets/class-asset-manager.php, line 28

class Asset_Manager

Tags: @since 1.1.0

Constants

ConstantVisibilityValueLine
TRANSIENT_PREFIXpublic\'wppo_page_assets_\'35

Properties

PropertyVisibilityTypeDefaultLine
$protected_scriptsprivate staticarrayarray( \'jquery\', \'jquery-core\', \'jquery-migrate\', \'wp-i18n\', \'wp-hooks\', \'wp-api-fetch\', \'wp-url\', \'wp-polyfill\', \'admin-bar\', \'heartbeat\', )43
$protected_stylesprivate staticarrayarray( \'admin-bar\', \'dashicons\', \'wp-block-library\', )62
$size_cacheprivate staticarrayarray()77

public __construct()

public function __construct()

Constructor.

Tags: @since 1.1.0

Source: includes/Assets/class-asset-manager.php, line 90

public dequeue_selected_assets()

public function dequeue_selected_assets(): void

Dequeue and deregister assets that the admin has disabled for this post.

Return: void.

Tags: @since 1.1.0

Source: includes/Assets/class-asset-manager.php, line 108

public capture_page_assets()

public function capture_page_assets(): void

Capture all enqueued scripts and styles on the current page.

Return: void.

Tags: @since 1.1.0

Source: includes/Assets/class-asset-manager.php, line 168

publicstatic resolve_asset_size()

public static function resolve_asset_size($src)

Resolve the on-disk size of an enqueued asset source.

ParameterTypeDefaultDescription
$srcstring—The registered asset `src` (URL or path).

Return: int|null — Local file size in bytes, or null when unknown.

Tags: @since 2.3.0

Source: includes/Assets/class-asset-manager.php, line 268

publicstatic get_asset_suggestions()

public static function get_asset_suggestions($assets, =51200 $threshold)

Suggest heavy, non-protected assets worth reviewing for this page.

ParameterTypeDefaultDescription
$assetsarray—Captured page assets (`scripts`/`styles` lists).
$threshold=51200—Minimum size in bytes for a suggestion. Defaults to 50 KB.

Return: array — List of `array( \’type\’ => \’script\’|\’style\’, \’handle\’ => string, \’size\’ => int )`.

Tags: @since 2.3.0

Source: includes/Assets/class-asset-manager.php, line 322

publicstatic get_page_assets()

public static function get_page_assets($post_id)

Get captured assets for a specific post.

ParameterTypeDefaultDescription
$post_idint—The post ID to get assets for.

Return: array|false — The captured assets array, or false if not found.

Tags: @since 1.1.0

Source: includes/Assets/class-asset-manager.php, line 381

publicstatic get_protected_scripts()

public static function get_protected_scripts()

Get the list of protected script handles.

Return: array — List of protected script handles.

Tags: @since 1.1.0

Source: includes/Assets/class-asset-manager.php, line 391

publicstatic get_protected_styles()

public static function get_protected_styles()

Get the list of protected style handles.

Return: array — List of protected style handles.

Tags: @since 1.1.0

Source: includes/Assets/class-asset-manager.php, line 401

Hooks

Hooks referenced in includes/Assets/class-asset-manager.php:

HookTypeLineNotes
wppo_page_asset_sizefilter277—
wppo_asset_suggestion_thresholdfilter330—