title: jQuery script not running in JSF page using ui:composition
body: <p>I'm trying to get my jQuery code to run in my JSF page which uses <code>ui:composition</code>. I've tried so many different things including putting in <code>&lt;head&gt;</code> tags, <code>&lt;h:head&gt;</code> tags, eventually I came across <a href="https://stackoverflow.com/questions/9000101/how-to-add-different-javascripts-on-a-page-when-using-uicomposition">this answer</a> and so tried using the solution there, but to no avail.</p>
  
  <p>At the top of the script is an <code>alert("ready")</code> so I'll know that the script has loaded, but so far I've not gotten it to work. The jQuery code itself works fine (I've tested it in a JSFiddle and on a normal HTML page).</p>
  
  <p>Any suggestions would be helpful!</p>
  
  <hr>
  
  <h2>My jQuery:</h2>
  
  <pre><code>$(document).ready(function () {
      alert("ready");
      ...
      ...
  });
  </code></pre>
  
  <hr>
  
  <h2>This is my JSF page:</h2>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                  xmlns:h="http://xmlns.jcp.org/jsf/html"
                  xmlns="http://www.w3.org/1999/xhtml"
                  template="./_Template.xhtml"&gt;
  
      &lt;ui:define name="script"&gt;&lt;h:outputScript library="javascript" name="jquery-2.1.3.min.js" target="head" /&gt; &lt;/ui:define&gt;
      &lt;ui:define name="script"&gt;&lt;h:outputScript library="javascript" name="jquery-ui.min.js" target="head"/&gt; &lt;/ui:define&gt;
      &lt;ui:define name="script"&gt;&lt;h:outputScript library="javascript" name="1.js"/&gt; &lt;/ui:define&gt;
  
      &lt;ui:define name="top"&gt;
          &lt;h1&gt;Weather App&lt;/h1&gt;
      &lt;/ui:define&gt;
      &lt;ui:define name="left"&gt;
          &lt;h3&gt;Navigation&lt;/h3&gt;
          ...
      &lt;/ui:define&gt;
      &lt;ui:define name="content"&gt;
          &lt;form name="search_form" id="searchForm" method="GET" action="search_results.html"&gt;
              &lt;label for="searchBox"&gt;Search&lt;/label&gt;
              &lt;input type="text" id="searchBox" name="searchString" /&gt;
              &lt;button name="searchKeyword" id="searchKeyword"&gt;Submit&lt;/button&gt;
          &lt;/form&gt;      
      &lt;/ui:define&gt;
  &lt;/ui:composition&gt;
  </code></pre>