Docly Developers
Function Updated 23 Oct 2026

assetUrl(path)

Returns a versioned URL for a static asset so the browser fetches a fresh copy after each publish (cache-busting). Typically used in <script src> and <link href> for JS/CSS bundles.

Parameters

pathstringrequired

Relative path to the asset, e.g. /assets/js/bundle.js. External URLs (containing :// or starting with //) are returned unchanged.

Returns

A string: path with ?v=<version> appended. The version is the site's last-modified timestamp (yyyyMMddHHmmss), shared across the whole site and changed on every publish. If the path already has a query string, &v= is appended instead. External URLs (http(s):// or //) are returned unchanged.

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
<script src="#docly.assetUrl('/assets/js/bundle.js')#"></script>
<link href="#docly.assetUrl('/assets/css/bundle.css')#" rel="stylesheet">

// /assets/js/bundle.js        ->  /assets/js/bundle.js?v=20260714183000
// /assets/js/app.js?lang=no   ->  /assets/js/app.js?lang=no&v=20260714183000
// https://cdn.x.com/lib.js     ->  https://cdn.x.com/lib.js   (unchanged)