@@ -12,6 +12,41 @@ sale app, the website or even the mobile application are different. Also, some
12
12
assets may be large, but are seldom needed: in that case we may want them
13
13
to be :ref: `loaded lazily (on demand) <frontend/assets/lazy_loading >`.
14
14
15
+ Asset types
16
+ ===========
17
+
18
+ There are three different asset types: code (`js ` files), style (`css ` or `scss `
19
+ files) and templates (`xml ` files).
20
+
21
+ Code
22
+ Odoo supports :ref: `three different kinds of javascript files<frontend/js_modules> `.
23
+ All these files are then processed (native JS modules are transformed into odoo
24
+ modules), then minified (if not in `debug=assets ` :ref: `mode <frontend/framework/assets_debug_mode >`)
25
+ and concatenated. The result is then saved as a file attachment. These file
26
+ attachments are usually loaded via a `<script> ` tag in the `<head> ` part of
27
+ the page (as a static file).
28
+
29
+ Style
30
+ Styling can be done with either `css ` or `scss <https://sass-lang.com/ >`_. Like
31
+ the javascript files, these files are processed (`scss ` files are converted into
32
+ `css `), then minified (again, if not in `debug=assets ` :ref: `mode <frontend/framework/assets_debug_mode >`)
33
+ and concatenated. The result is then saved as a file attachment. They are
34
+ then usually loaded via a `<link> ` tag in the `<head> ` part of the page (as
35
+ a static file).
36
+
37
+ Template
38
+ Templates (static `xml ` files) are handled in a different way: they are simply
39
+ read from the file system whenever they are needed, and concatenated.
40
+
41
+ Whenever the browser loads odoo, it calls the `/web/webclient/qweb/ ` controller
42
+ to fetch the :ref: `templates <reference/qweb >`.
43
+
44
+ It is useful to know that in most cases, a browser only performs a request the
45
+ first time it loads a page. This is because each of these assets are
46
+ associated with a checksum, which is injected into the page source. The checksum
47
+ is then added to the url, which means that it is possible to safely set the cache
48
+ headers to a long period.
49
+
15
50
Bundles
16
51
=======
17
52
63
98
64
99
- `web.qunit_mobile_suite_tests `: mobile specific qunit testing code
65
100
66
- Asset types
67
- ===========
68
-
69
- There are three different asset types: code (`js ` files), style (`css ` or `scss `
70
- files) and templates (`xml ` files).
71
-
72
- Code
73
- Odoo supports :ref: `three different kinds of javascript files<frontend/js_modules> `.
74
- All these files are then processed (native JS modules are transformed into odoo
75
- modules), then minified (if not in `debug=assets ` :ref: `mode <frontend/framework/assets_debug_mode >`)
76
- and concatenated. The result is then saved as a file attachment. These file
77
- attachments are usually loaded via a `<script> ` tag in the `<head> ` part of
78
- the page (as a static file).
79
-
80
- Style
81
- Styling can be done with either `css ` or `scss <https://sass-lang.com/ >`_. Like
82
- the javascript files, these files are processed (`scss ` files are converted into
83
- `css `), then minified (again, if not in `debug=assets ` :ref: `mode <frontend/framework/assets_debug_mode >`)
84
- and concatenated. The result is then saved as a file attachment. They are
85
- then usually loaded via a `<link> ` tag in the `<head> ` part of the page (as
86
- a static file).
87
-
88
- Template
89
- Templates (static `xml ` files) are handled in a different way: they are simply
90
- read from the file system whenever they are needed, and concatenated.
91
-
92
- Whenever the browser loads odoo, it calls the `/web/webclient/qweb/ ` controller
93
- to fetch the :ref: `templates <reference/qweb >`.
94
-
95
- It is useful to know that in most cases, a browser only performs a request the
96
- first time it loads a page. This is because each of these assets are
97
- associated with a checksum, which is injected into the page source. The checksum
98
- is then added to the url, which means that it is possible to safely set the cache
99
- headers to a long period.
100
101
101
- Operations on asset bundles
102
- ===========================
102
+ Operations
103
+ ----------
103
104
104
105
Typically, handling assets is simple: you just need to add some new files
105
106
to a frequently used bundle like `assets_common ` or `assets_backend `. But there are other operations
@@ -111,7 +112,7 @@ in manifests higher up in the hierarchy or in ``ir.asset`` records with a lower
111
112
sequence.
112
113
113
114
`append `
114
- --------
115
+ ~~~~~~~~
115
116
116
117
This operation adds one or multiple file(s). Since it is the most common
117
118
operation, it can be done by simply using the file name:
@@ -127,7 +128,7 @@ glob pattern at the end of the bundle. Obviously, the pattern may also be direct
127
128
a single file path.
128
129
129
130
`prepend `
130
- ---------
131
+ ~~~~~~~~~
131
132
132
133
Add one or multiple file(s) at the beginning of the bundle.
133
134
@@ -142,7 +143,7 @@ syntax: `('prepend', <path>)`.
142
143
],
143
144
144
145
`before `
145
- --------
146
+ ~~~~~~~~
146
147
147
148
Add one or multiple file(s) before a specific file.
148
149
@@ -158,7 +159,7 @@ file. It is declared by replacing the normal path with a 3-element tuple
158
159
],
159
160
160
161
`after `
161
- -------
162
+ ~~~~~~~
162
163
163
164
Add one or multiple file(s) after a specific file.
164
165
@@ -173,7 +174,7 @@ It is declared by replacing the normal path with a 3-element tuple
173
174
],
174
175
175
176
`include `
176
- ---------
177
+ ~~~~~~~~~
177
178
178
179
Use nested bundles.
179
180
@@ -189,7 +190,7 @@ specify the sub bundle as a pair `('include', <bundle>)` like this:
189
190
],
190
191
191
192
`remove `
192
- --------
193
+ ~~~~~~~~
193
194
194
195
Remove one or multiple file(s).
195
196
@@ -204,7 +205,7 @@ can be done using the `remove` directive by specifying a pair
204
205
],
205
206
206
207
`replace `
207
- ---------
208
+ ~~~~~~~~~
208
209
209
210
Replace an asset file with one or multiple file(s).
210
211
@@ -220,7 +221,7 @@ the `replace` directive, using a 3-element tuple `('replace', <target>, <path>)`
220
221
221
222
222
223
Loading order
223
- =============
224
+ -------------
224
225
225
226
The order in which assets are loaded is sometimes critical and must be deterministic,
226
227
mostly for stylesheets priorities and setup scripts. Assets in Odoo are processed
@@ -235,7 +236,7 @@ as follows:
235
236
236
237
#. All modules declaring assets for said bundle in their manifest apply their
237
238
assets operations to this list. This is done following the order of modules dependencies
238
- (e.g. `web ` assets is processed before ' website' ). If a directive tries to add
239
+ (e.g. `web ` assets is processed before ` website ` ). If a directive tries to add
239
240
a file already present in the list, nothing is done for that file. In other word,
240
241
only the first occurrence of a file is kept in the list.
241
242
@@ -267,8 +268,8 @@ in the list before all the others included in the glob.
267
268
268
269
.. _frontend/assets/lazy_loading :
269
270
270
- Lazy loading assets
271
- ===================
271
+ Lazy loading
272
+ ============
272
273
273
274
It is sometimes useful to load files and/or asset bundles dynamically, for
274
275
example to only load a library once it is needed. To do that, the Odoo framework
0 commit comments