se lazy loading to ensure the JS import is only added the // first time this method is called. if (headElements == null) { // Get the head elements from the super implementation headElements = super.getHeadElements(); JsImport jsImport = new JsImport("/js/js-library.js"); headElements.add(jsImport); } return headElements; } } The
jsImport instance will be rendered as follows (assuming the context path is
myApp):
<script type="text/javascript" href="/myApp/js/js-library.js"></script>