diff --git a/docs/framework/asset-builder.md b/docs/framework/asset-builder.md index 2aa66ff4..84d9eeea 100644 --- a/docs/framework/asset-builder.md +++ b/docs/framework/asset-builder.md @@ -1,13 +1,17 @@ # Asset Builder The `AssetBuilder` manages lazily-generated assets, such as aggregated -JS/CSS files. Lazy assets are simultaneously: +JS/CSS files. The first time you request a lazy asset, the `AssetBuilder` +fires a hook which builds the content. The content is stored in a cache +file, and subsequent requests use the cache file. + +Lazy assets are simultaneously dynamic and static: * __Dynamic__: They vary depending on the current system configuration. - You cannot lock-in a correct version of the asset because each + You cannot lock-in a singular version of the asset because each installation may need a slightly different version. * __Static__: Within a given site, the asset is not likely to change. - It could even be served directly by the web-server (without the overhead + It can even be served directly by the web-server (without the overhead of PHP/CMS/Civi bootstrap) !!! note "Example: Batch loading Angular HTML" @@ -17,18 +21,15 @@ JS/CSS files. Lazy assets are simultaneously: This asset is _dynamic_ because extensions can add or modify HTML templates. Two different sites would have different HTML templates - (depending on the mix of extensions). Yet, within a particular - site/configuration, the content is _static_ because the HTML doesn't - actually change at runtime. - -The `AssetBuilder` addresses this use-case with *lazy* building. Assets are -not distributed as part of `git` or `tar.gz`. Rather, the first time you -use an asset, it fires off a hook which builds the content. The content is -stored in a cache file. + (depending on the mix of extensions). Yet, within a particular site, + the content is _static_ because the HTML doesn't actually change at + runtime. !!! tip "Tip: Caching and development" If you are developing or patching assets, then the caching behavior may - get distracting. To bypass the cache, enable **debug mode**. + get distracting. To bypass the cache, navigate to + __Administer > System Settings > Debugging__ and enable debugging. + ## Usage: Simple asset @@ -112,7 +113,7 @@ function mymodule_civicrm_buildAsset($asset, $params, &$mimeType, &$content) { ``` !!! note "Note: Parmaters and caching" - Each combination of ($asset,$params) will be cached separately. + Each combination of (`$asset`,`$params`) will be cached separately. !!! tip "Tip: Economize parameter size" In debug mode, all parameters are passed as part of the URL. `AssetBuilder`