开发者

Include a javascript for composite component only once in a page despite of composite components themselves used multiple times

开发者 https://www.devze.com 2023-04-04 03:29 出处:网络
How do I include a JavaScript code only once for 开发者_如何学运维multiple usages of acomposite component on a page?

How do I include a JavaScript code only once for 开发者_如何学运维multiple usages of a composite component on a page?

Initially I had put I put the JS code inside the cc:implementation tags but that lead to the script being included each time with the components. I want to avoid this condition and include the JavaScript only once even if component has been used multiple times on a page.


Include the static part of that JS code as a standalone JS file by <h:outputScript> with target="head". It'll be rendered into <h:head> just once.

<cc:implementation>
    <h:outputScript name="js/myCompositeHelper.js" target="head" />
    ...
</cc:implementation>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号