Enable javascript for the composite component only once per page, although the composite components themselves are used multiple times

How to include JavaScript code only once for multiple use of a composite component on a page?

At first I put the JS code inside the cc:implementation tags, but this led to the script being included every time with the components. I want to avoid this condition and enable JavaScript only once, even if the component was used several times on the page.

+7
source share
1 answer

Include the static part of this JS code as a separate JS file using <h:outputScript> using target="head" . It will be displayed in <h:head> only once.

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

All Articles