ScriptManager View code

The ScriptManager class provides the ability to queue javascript files for rendering on the frontend

package

CMS

since 2.3
license

GPL

Methods

__construct(\CmsApp $app) 

Constructor

Arguments

\CmsApp $app

get_script_priority() : integer

Returns the current script priority for addng new scripts.

Response

integer

set_script_priority(integer $val) 

Set the priority for scripts that are subsequently queued

Arguments

integer $val

An integer between 1 and 3. 1 being the higest priority.

queue_script(string $filename, integer $priority = null) 

Add a script to the queue.

Arguments

string $filename

The absolute path to the filename

integer $priority

An optional priority. If not specified the 'current' script priority will be used. Which defaults to 2.

render_scripts(string $output_path, string $entropy = null, boolean $force = false, boolean $allow_defer = true) 

Render scripts.

This method will analyze the queued scripts, and generate an output filename. if any of the queued scripts is newer than the generated output file (or the file does not exist) Then the scripts will be concatenated and placed in the output file.

Arguments

string $output_path

The location to place the concatenated scripts

string $entropy

Some aditional entropty to use when generating the output filename.

boolean $force

If true the output will be generated without analyzing whether input files have changed.

boolean $allow_defer

Enable the defer attribute on the script tag