How to include external Javascript file in a JSF page

后端 未结 1 1662
攒了一身酷
攒了一身酷 2020-12-10 20:26

I want to include the URL of jQuery UI http://code.jquery.com/ui/1.9.0/jquery-ui.js in my JSF page. I saw many questions which said

相关标签:
1条回答
  • 2020-12-10 20:49

    Just use plain HTML <script> element the usual way.

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

    The <h:outputScript> can only refer local scripts. You'll only miss its dynamic versioning, modularity and relocation advantages, but that should technically not harm for a static and external script.

    It's however possible to use a custom ResourceHandler to change the URL of a <h:outputScript> to be an external URL for pure CDN purposes. OmniFaces CDNResourceHandler is such an example.


    Unrelated to the concrete problem, PrimeFaces components are built around jQuery/UI. Are you absolutely positive that you need a separate instance of jQuery UI library?

    0 讨论(0)
提交回复
热议问题