load(file) Last updated: 17. Oct 2026

Loads a file from the site, runs the #JS code it contains and returns the result as text.

See also: Include getJson

Parameters

Name Type Description
file string

Path to the file, from the site root.

Returns

The processed content as a string. null when the path is empty, and the text Load failed for '<path>' when the file does not exist.

A file that loads itself, directly or through other files, is stopped with the text Infinite loop stopped for ….

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// Render a shared snippet and use the result
let footer = docly.load("#/Snippets/footer.hash");
write(footer);

Output

The JS code above produces the output shown below:
Load failed for '#/Snippets/footer.hash'