@@ -15,12 +15,80 @@ We often want to ship a website with a static resource, such as an image, icon,
1515For this, we need to register static resources.
1616
1717
18+ (classic-ui-static-resources-registering-label)=
19+ ## Registering javascript and css
20+
21+ To register a static resource in Plone 6, we need to use the ` plone.base.interfaces.resources.IBundleRegistry ` interface.
22+
23+ The following example registers a Javascript resource in ` browser/profiles/default/registry ` of your Plone 6 project.
24+ The js files have to be in the ` browser/static ` folder of your Plone 6 project.
25+
26+ ``` xml
27+ <registry >
28+ <records interface =" plone.base.interfaces.resources.IBundleRegistry" prefix =" plone.bundles/jscript" >
29+ <value key =" enabled" >True</value >
30+ <value key =" jscompilation" >++plone++myproject.site/javascript.min.js</value >
31+ <value key =" load_async" >False</value >
32+ <value key =" load_defer" >False</value >
33+ <value key =" depends" >plone</value >
34+ </records >
35+ </registry >
36+ ```
37+
38+ You can register a CSS resource in the same way.
39+
40+ ``` xml
41+ <registry >
42+ <records interface =" plone.base.interfaces.resources.IBundleRegistry" prefix =" plone.bundles/css" >
43+ <value key =" enabled" >True</value >
44+ <value key =" csscompilation" >++plone++myproject.site/style.min.css</value >
45+ <value key =" depends" >plone</value >
46+ </records >
47+ </registry >
48+ ```
49+
50+ Registering a js file and a css file in the same bundle is also possible.
51+
52+ ``` xml
53+ <registry >
54+ <records interface =" plone.base.interfaces.resources.IBundleRegistry" prefix =" plone.bundles/css" >
55+ <value key =" enabled" >True</value >
56+ <value key =" csscompilation" >++plone++myproject.site/style.min.css</value >
57+ <value key =" jscompilation" >++plone++myproject.site/javascript.min.js</value >
58+ <value key =" load_async" >False</value >
59+ <value key =" load_defer" >False</value >
60+ <value key =" depends" >plone</value >
61+ </records >
62+ </registry >
63+ ```
64+
1865(classic-ui-static-resources-available-attributeslabel)=
1966
2067## Available attributes
2168
69+ The following attributes are available for registering a static resource:
70+
71+ ` enabled `
72+ : Whether the bundle is enabled or not. If it is disabled, the bundle will not be loaded.
73+
74+ ` jscompilation `
75+ : The path to the compiled js file.
76+
77+ ` csscompilation `
78+ : The path to the compiled css file.
79+
80+ ` depends `
81+ : A list of bundles that this bundle depends on.
82+
83+ ` load_async `
84+ : Whether the bundle should be loaded asynchronously or not. * Only JS*
85+
86+ ` load_defer `
87+ : Whether the bundle should be loaded deferred or not. * Only JS*
88+
2289
2390(classic-ui-static-resources-loading-order-label)=
2491
2592## Loading order of resources
2693
94+ ` depends ` is used to define the loading order of resources, by specifying the name of the depending bundle.
0 commit comments