assetUrl(path) Last updated: 15. Jul 2026
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
| Name | Type | Description |
|---|---|---|
| path | string | 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
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.<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) Output
The #JS code above produces the output shown below:The asset path with ?v=<version> appended, e.g. /assets/js/bundle.js?v=20260714183000. The version is shared across the whole site and changes on every publish, so even unchanged bundles get a new URL after a publish (deliberate: safe over clever).