11 Replies Latest reply on Feb 27, 2012 8:23 AM by lfryc

    Load JQuery From CDN


      I love that Richfaces uses JQuery as this has long been my choice of a js framework, however I wish that I could load it from Google's CDN or another CDN w/ fast ssl negotation etc. Is there a way (other than a servlet filter) to suppress the version used by Richfaces so I can include a preferred jQuery?

        • 1. Load JQuery From CDN

          I'm using btw. Thanks!

          • 2. Load JQuery From CDN

            I would absolutely *LOVE* to be able to easily configure this in RichFaces.

            • 3. Re: Load JQuery From CDN

              If you don't use any jquery component, then you can assume the one that comes packed

              with richfaces is suppressed.


              To include your own special jquery version, follow the below logic:


              To include a script resource, use the outputScript tag:


              <h:outputScript name="jQuery_personal.js" library="javascript" target="head" />


              If the target attribute is head or body, the script is appended to the "head" or "body"

              facet of the root component, which means that it appears at the end of the head

              or body in the generated HTML. If there is no target element, the script is

              inserted in the current location.

              • 4. Re: Load JQuery From CDN

                Sorry, maybe I wasn't totally clear. I do want to use a jQuery component (client side validation in this case -- <rich:validator />). I don't want to use the jQuery bundled w/ Richfaces for several reasons, but I do want to use the components. What I'd like to be able to do is suppress the version bundled w/ Richfaces and include my own reference to a CDN jQuery, as in:




                This way I can use a compressed copy (the version is Richfaces is totally uncompressed) with fast resolution for clients (Google's ssl negotiation is sick and the sites I work on are served 100% over ssl). Make sense?

                • 5. Load JQuery From CDN



                  Add the following into web.xml:







                  And create META-INF/richfaces/static-resource-mappings.properties resource in classpath:



                  • 6. Load JQuery From CDN

                    sick. thank you! trying this out now.

                    • 7. Load JQuery From CDN

                      I tried those instructions verbatim and it doesn't seem to work. Is #{resourceLocation} illustrative -- as in should it actually be replaced with the path to the properites file -- META-INF/richfaces/static-resource-mappings.properties ?

                      • 8. Load JQuery From CDN

                        No, not illustrative. Should be added as is.

                        • 9. Load JQuery From CDN

                          My bad. Got it working -- sorry for the double/triple posts.


                          So this is pretty slick. I suppose that any of the other static resources (richfaces.js etc.) could be distributed via CDN and referenced the same way. Richfaces rocks. Thank you so much!

                          • 10. Load JQuery From CDN



                            Actually this is what we use for GAE (Google app Engine) integration. There is Maven resources plugin that generates pack of resources for component images, CSS and scripts that can be then deployed to CDN.

                            • 11. Re: Load JQuery From CDN

                              Since RichFaces 4.2, you can use Resource Mapping feature to load resources from CDN, refer to Resource Mapping feature documentation, this particular example is provided there.