@@ -312,24 +312,18 @@ You can now use the ``asset()`` function:
312
312
{# the JS file lives at "public/bundles/acme/js/loader.js" #}
313
313
<script src="{{ asset('bundles/acme/js/loader.js') }}"></script>
314
314
315
- Using the ``asset() `` function is recommended for two reasons:
316
-
317
- * It automatically takes care of versioning your assets with
318
- :doc: `Symfony's AssetMapper </frontend >`
319
-
320
- * If your application lives at the root of your host (e.g. ``https://example.com ``),
321
- then the rendered path should be ``/images/logo.png ``. But if your application
322
- lives in a subdirectory (e.g. ``https://example.com/my_app ``), each asset path
323
- should render with the subdirectory (e.g. ``/my_app/images/logo.png ``). The
324
- ``asset() `` function takes care of this by determining how your application is
325
- being used and generating the correct paths accordingly.
326
-
327
- .. tip ::
328
-
329
- The ``asset() `` function supports various cache busting techniques via the
330
- :ref: `version <reference-framework-assets-version >`,
331
- :ref: `version_format <reference-assets-version-format >`, and
332
- :ref: `json_manifest_path <reference-assets-json-manifest-path >` configuration options.
315
+ Using the ``asset() `` function is recommended for these reasons:
316
+
317
+ * **Asset versioning **: ``asset() `` appends a version hash to asset URLs for
318
+ cache busting. This works both via :doc: `AssetMapper </frontend >` and the
319
+ :doc: `Asset component </components/asset >` (see also the
320
+ :ref: `assets configuration options <reference-assets >`, such as ``version ``
321
+ and ``version_format ``).
322
+
323
+ * **Application portability **: whether your app is hosted at the root
324
+ (e.g. ``https://example.com ``) or in a subdirectory (e.g. ``https://example.com/my_app ``),
325
+ ``asset() `` generates the correct path (e.g. ``/images/logo.png `` vs ``/my_app/images/logo.png ``)
326
+ automatically based on your app's base URL.
333
327
334
328
If you need absolute URLs for assets, use the ``absolute_url() `` Twig function
335
329
as follows:
0 commit comments