Last modified by Eleni Cojocariu on 2026/05/12 10:01

Show last authors
1 It is possible to define a module as part of the importmap, but to also make it eager, meaning that the module is going to be loaded an executed directly on page load.
2
3 == Step 1 ==
4
5 Add the dependency you wish to load eagerly
6
7 {{code language="xml"}}
8 <?xml version="1.0" encoding="UTF-8"?>
9 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
10 <dependencies>
11 <!-- ... -->
12 <dependency>
13 <groupId>my.group.id</groupId>
14 <artifactId>my-webjar</artifactId>
15 <scope>runtime</scope>
16 </dependency>
17 <!-- ... -->
18 </dependencies>
19 </project>
20 {{/code}}
21
22 == Step 2 ==
23
24 Declare theĀ ##xwiki.extension.javascript.modules.importmap## property. See the ##!## at the start of the value.
25
26 {{code language="xml"}}
27 <?xml version="1.0" encoding="UTF-8"?>
28 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
29 <properties>
30 <xwiki.extension.javascript.modules.importmap>
31 {
32 "module-id": "!my.group.id:my-webjar/index.prod.js"
33 }
34 </xwiki.extension.javascript.modules.importmap>
35 </properties>
36 </project>
37 {{/code}}
38
39 == Final result ==
40
41 {{code language="xml"}}
42 <?xml version="1.0" encoding="UTF-8"?>
43 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44 <modelVersion>4.0.0</modelVersion>
45 <parent>
46 <groupId>org.xwiki.platform</groupId>
47 <artifactId>xwiki-platform-livedata</artifactId>
48 <version>18.1.0-SNAPSHOT</version>
49 </parent>
50 <packaging>webjar-node</packaging>
51 <artifactId>xwiki-platform-livedata-webjar</artifactId>
52 <properties>
53 <xwiki.extension.javascript.modules.importmap>
54 {
55 "module-id": "!my.group.id:my-webjar/index.prod.js"
56 }
57 </properties>
58 <dependencies>
59 <dependency>
60 <groupId>my.group.id</groupId>
61 <artifactId>module-id</artifactId>
62 <scope>runtime</scope>
63 </dependency>
64 </dependencies>
65 </project>
66 {{/code}}

Get Connected