I'm trying to call an external javascript function from thymeleaf.
HTML
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Test</title>
<script data-th-inline="javascript" th:src="@{/js/helper.js}">
window.onload = function() {
console.log("start")
var result = helperFunction()
console.log("external function result: " + result)
console.log("end")
};
</script>
</head>
<body>
</body>
</html>
Java script file /js/helper.js
function helperFunc() {
return "test"
}
Is it possible to call that js function from within script tags?
Thank you