Skip to content

Commit

Permalink
Use WebJars versioned URLs
Browse files Browse the repository at this point in the history
In order to improve efficiency (see spring-projects/spring-framework#27619)
and allow native image compatibility, this commit uses WebJars versioned URLs
which are supported out of the box on Spring Boot via /META-INF/resources
default resource location configuration, removing the need to use
webjars-locator-core dependency and WebJarsResourceResolver.

I have been able to measure a consistent 5% startup time improvement on
the JVM with that simple change on my local machine.
  • Loading branch information
sdeleuze committed Oct 16, 2022
1 parent 777e183 commit dc1315f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
1 change: 0 additions & 1 deletion build.gradle
Expand Up @@ -25,7 +25,6 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'javax.cache:cache-api'
runtimeOnly 'org.springframework.boot:spring-boot-starter-actuator'
runtimeOnly 'org.webjars:webjars-locator-core'
runtimeOnly "org.webjars.npm:bootstrap:${webjarsBootstrapVersion}"
runtimeOnly "org.webjars.npm:font-awesome:${webjarsFontawesomeVersion}"
runtimeOnly 'org.ehcache:ehcache'
Expand Down
4 changes: 0 additions & 4 deletions pom.xml
Expand Up @@ -89,10 +89,6 @@
</dependency>

<!-- webjars -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator-core</artifactId>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>bootstrap</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/fragments/layout.html
Expand Up @@ -17,7 +17,7 @@
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->

<link th:href="@{/webjars/font-awesome/css/font-awesome.min.css}" rel="stylesheet">
<link th:href="@{/webjars/font-awesome/4.7.0/css/font-awesome.min.css}" rel="stylesheet">
<link rel="stylesheet" th:href="@{/resources/css/petclinic.css}" />

</head>
Expand Down Expand Up @@ -87,7 +87,7 @@
</div>
</div>

<script th:src="@{/webjars/bootstrap/dist/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/webjars/bootstrap/5.1.3/dist/js/bootstrap.bundle.min.js}"></script>

</body>

Expand Down

0 comments on commit dc1315f

Please sign in to comment.