How to ensure jQuery loading in RichFaces?

I am using jQuery on my page. However, I do NOT use RichFaces tags on every page. Subsequently, jQuery does NOT introduce RF on every page. To avoid loading an additional jQuery library, how can I properly instruct RichFaces to load my own jQuery library?

This is a problem because the RF-jQuery library overwrites my custom jQuery, which I am loading. In addition, RF-jQuery libraries are always the latest downloadable libraries, which is also bad because I need jquery-ui.js and jquery-migrate-1.2.1.min.js load AFTER the jQuery library is loaded.

 <head> <!-- JS --> <span id="out"> Richfaces-jQuery enforce with a4j:outputPanel </span> <script src="/ccms/resources/js/jquery-ui.js"></script> <script src="/ccms/resources/js/jquery-migrate-1.2.1.min.js"></script> <!-- The CK editor --> <script src="/ccms/resources/ckeditor_4_2_custom/ckeditor.js"></script> <script src="/ccms/resources/js/jquery.capty.min.js"></script> <!-- &lt;ui:debug hotkey=&quot;x&quot; /&gt; --> <script type="text/javascript" src="/ccms/javax.faces.resource/jsf.js.jsf?ln=javax.faces&amp;stage=Development"></script> <script type="text/javascript" src="/ccms/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.3.Final/Packed/jquery.js"></script> <script type="text/javascript" src="/ccms/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.3.Final/Packed/packed/packed.js"></script> <link type="text/css" rel="stylesheet" href="/ccms/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.3.Final/Packed/DEFAULT/packed/packed.css" /> </head> 
+4
source share
3 answers

RichFaces 4.x-bundled jQuery is available as follows:

 <h:outputScript name="jquery.js" /> 

Yes, amazingly without a library !

You only need to make sure that you use <h:head> instead of <head> . I also highly recommend loading your own JS resources with <h:outputScript> .

+6
source

You can force jQuery to load by adding this (works with RichFaces 3.x):

 <a4j:loadScript src="resource://jquery.js" /> 

For RichFaces 4.x see this topic: replacing RichFaces 4 for <a4j: loadScript>

+2
source

If your h:outputScript not inside h:head , add the target="head" parameter to make sure that the library is included only once:

 <h:outputScript name="jquery.js" target="head"/> 
0
source

Source: https://habr.com/ru/post/1500262/


All Articles