Reputation: 4912
I'm using Spring Boot / MVC and learning Thymeleaf.
Let's say i have my scripts on another server.
https://staticserver.com/main.js
I've added the '//staticserver.com' portion to my model as jsLocation
.
I want to do something on the lines of:
<script src="${jsLocation}/main.js"></script>
which would render
<script src="//staticserver.com/main.js"></script>
Upvotes: 2
Views: 21866
Reputation: 69
if your js file in /resources/static/js/
<script th:src="@{/resources/static/js/fileName.js}"> </script>
Upvotes: 2
Reputation: 15908
You can include external js file like below :
<script th:src="source to your external JS"></script>
You can refer below thread for more details as your query also relates to model.
Thymeleaf external javascript file shares the module attributes with html file
Upvotes: 4