How to include external Javascript file in JSF page

I want to add jQuery UI url http://code.jquery.com/ui/1.9.0/jquery-ui.js in my JSF page. I have seen many questions that said , but in none of the answers have I seen an example of how to include a url. The answers were only relevant if the js file is present in some project folder. <h:outputScript>

Can anyone help when should I include it on my page?

+3


source to share


1 answer


Just use a regular HTML <script>

element in the usual way.

<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>

      

<h:outputScript>

can only refer to local scripts. You will only miss your dynamic versions, modularity, and the benefits of moving, but that doesn't technically harm the static and external script.



However, it is possible to use a custom ResourceHandler

one to change the url <h:outputScript>

as an external url for clean CDN purposes. OmniFacesCDNResourceHandler

is such an example.


Unrelated to the specific issue, PrimeFaces components are built around jQuery / UI. Are you absolutely sure you want a separate instance of the jQuery UI library?

+13


source







All Articles