Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Developer Documentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
brienne
Developer Documentation
Commits
0a33f126
Commit
0a33f126
authored
7 years ago
by
totten
Browse files
Options
Downloads
Patches
Plain Diff
asset-builder.md - Copy-edits
parent
7e85d02c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/framework/asset-builder.md
+20
-19
20 additions, 19 deletions
docs/framework/asset-builder.md
with
20 additions
and
19 deletions
docs/framework/asset-builder.md
+
20
−
19
View file @
0a33f126
# 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
installation
may need a slightly different version.
*
__Static__: Within a given
site
, the asset is not likely to change.
It c
ould
even be served directly by the web-server (without the overhead
You cannot lock-in a
singular
version of the asset because each
deployment
may need a slightly different version.
*
__Static__: Within a given
deployment
, the asset is not likely to change.
It c
an
even be served directly by the web-server (without the overhead
of PHP/CMS/Civi bootstrap)
!!! note "Example: Batch loading Angular HTML"
...
...
@@ -16,19 +20,16 @@ JS/CSS files. Lazy assets are simultaneously:
bigger file and reduce the number of round-trip HTTP requests.
This asset is _dynamic_ because extensions can add or modify HTML
templates. Two different
site
s 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
templates. Two different
deployment
s would have different HTML
templates
(depending on the mix of extensions). Yet, within a
particular deployment
, 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.
!!! 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,12 +113,12 @@ 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`
will try to compress them, but
fundamentally: long
`$params`
will produce
long URLs.
!!! tip "Tip: Economize
on
parameter
s
"
In debug mode, all parameters are passed as part of the URL.
`AssetBuilder`
will try to compress them, but
it can only do so much.
Fundamentally, long
`$params`
will produce
long URLs.
## Other considerations
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment