Scripts

Manages the enqueuing of JavaScript files for the theme. It handles the inclusion of asset files, conditional script loading based on page type, and localization of JavaScript data.

  • Full name: \BigCommerce\Assets\Theme\Scripts

Methods

__construct

Scripts constructor.

public __construct(string $asset_directory, string $version, \BigCommerce\Assets\Theme\JS_Config $config, \BigCommerce\Assets\Theme\JS_Localization $localization): mixed

Initializes the Scripts class with the asset directory, version, and necessary dependencies.

Parameters:

ParameterTypeDescription
$asset_directorystringThe path to the plugin assets directory.
$versionstringThe version of the asset build.
$config\BigCommerce\Assets\Theme\JS_ConfigThe JS_Config object for configuration data.
$localization\BigCommerce\Assets\Theme\JS_LocalizationThe JS_Localization object for localized strings.

enqueue_scripts

Enqueues JavaScript files for the frontend.

public enqueue_scripts(): mixed

This method registers and enqueues the necessary JavaScript files for the theme, including manifest, vendor, and plugin scripts. It also conditionally loads the BigCommerce checkout SDK if the current page is the checkout page.



Automatically generated on 2025-01-21