title: Use of sec:authorize to load javascript
body: <p>I'm making a development using Spring MVC and thymeleaf. <br />
  I'm trying to use sec:authorize to load javascript. In other words, I only want this script to load when the user is authenticated.
  Here is code I'm trying to get to work:</p>
  
  <pre><code>&lt;script src="/js/jquery.min.js"
          th:src="@{/js/jquery.min.js}"&gt;&lt;/script&gt;
          &lt;script src="/js/submit.js"
          th:src="@{/js/submit.js}"&gt;&lt;/script&gt;
          &lt;script src="/js/url.js"
          th:src="@{/js/url.js}"&gt;&lt;/script&gt;
  
          &lt;!-- admin --&gt;
          &lt;script sec:authorize="isAuthenticated()" src="/js/jquery.simplemodal-1.4.4.js"
          th:src="@{/js/jquery.simplemodal-1.4.4.js}"&gt;&lt;/script&gt;
          &lt;script sec:authorize="isAuthenticated()" src="/js/admin.js"
          th:src="@{/js/admin.js}"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>These last 2 resources I'm trying to use sec:authorize to load but they seem to handle every time I load the page. Is this a valid way to use sec:authorize? Id it isn't, is there any way to do this?</p>