VV::js()

Include a JavaScript source file into a page which will be automatically minified and inlined.

Parameters

string

$pathname

Path to a JavaScript source file.

Appending ".js" to the filename is optional. If omitted, the extension is infered.

bool

$relative

Flag which when set to:

  1. true

    Will make $pathname look for a JavaScript source file relative to root_path.

  2. false

    Will make $pathname look for a JavaScript source file relative to the root of the whole filesystem.

Return value

string

Returns a minified version of the included JavaScript source file as a string. If a file can not be found at $pathname, an empty string is returned.


Examples

Importing a JavaScript source file

In this example we're importing a JavaScript source file from /public/assets/js/script.js relative from root_path.