Search code examples
javascriptjsffaceletscomposite-component

Include a JS script not in the header but in the footer of the page?


I'm doing a JSF Composite, but I m having a hard time with including my JS scripts inside. I'm tying this:

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

Here are the questions:

  1. For some reason, I cannot put a path inside of the name attribute, I get an error. What am I doing wrong?
  2. I know of target='head', but for websites, it's better to put the JS in the footer, so how can I do that?

Thanks for any help. PS: I've seen this, but Include a javascript for composite component only once in a page despite of composite components themselves used multiple times


Solution

  • 1. For some reason, I cannot put a path inside of the name attribute, I get an error. What am I doing wrong?

    I have no idea what your problem is as you didn't describe the error in detail (the error message is usually the whole answer at its own). In any way, the markup and the name looks fine so far, assuming that it's indeed placed in /resources folder of public webcontent.


    2. I know of target='head', but for websites, it's better to put the JS in the footer, so how can I do that?

    Use target="body". It'll end up in end of body.