Thymeleaf - Include content of fragment

try the below

<div th:fragment="assets" th:remove="tag">
    <script src="myscript"></script>
    <script src="myscript2"></script>
</div>

You can use th:block to include only content of a block.

Define your fragment like -

<th:block th:fragment="assets">
    <script src="myscript"></script>
    <script src="myscript2"></script>
</th:block>

And include like this -

<th:block th:include="fragments/assets :: assets"></th:block>

Hope this will help you :)