3 Replies Latest reply on Jun 18, 2012 10:34 AM by hypnotec

    Multiple versions of a clientlib

    joel_triemstra Level 1

      Say I'm building a component that requires jQuery. I'm reasonably confident that updates to jQuery over the next couple years are not going to break the functionality I'm using. I'm expecting that a variety of sites for my client will use this component over the next couple years, and I would like to allow those site developers to use the most current version of jQuery at the time they are developing their site.


      One way to accomplish this would be to document that this component requires jQuery, and require the site developer to include the version they choose.


      But it seems like there ought to be a way to utilize the clientlib functionality to support this. If I were to just include a clientlib category of cq.jquery, I think I would be bound to using the same version of jQuery across the server. Is there a way that a developer could define the version of jQuery that a given site is using, and then components requiring jQuery would grab the correct version? And clientlibs that I'm writing to support my component which have dependencies on jQuery would also grab that version?

        • 1. Re: Multiple versions of a clientlib
          hypnotec Adobe Employee

          clientlibs don't support versioning at the moment. but what speaks against having the version in the category-name?


          e.g. my.jquery-1.3


          if you want to share aspects of jquery with all versions, you can have the version specific jquery libraries extend:


          e.g. my.jquery-1.3 depends on my.jquery.base.

          • 2. Re: Multiple versions of a clientlib
            joel_triemstra Level 1

            My thought is that if I include the version in the name, then all sites using this component are required to use that version of jQuery, or load multiple versions. The idea of extending a base jQuery is interesting. I don't know enough about how jQuery handles their own versioning to say for sure, but I think I'll have to look into that.

            • 3. Re: Multiple versions of a clientlib
              hypnotec Adobe Employee

              ok, so you're saying that the same component should use a different jQuery version depending on the site it is operated under. you can achieve this by having a "site-configuration" that specifies the version of jQuery to use per site. you can store the version information as a content property, either directly or e.g. in design mode. you can then use that version info dynamically to include the correct client lib category, e.g in your JSP:



              // get version from design with default = 1.3

              String versionInfo = currentDesign.getStyle(resource).get("versionInfo", "1.3");

              String clientlibCategory = "my.jquery-" + versionInfo;



              <cq:includeClientLib categories="<%=clientlibCategory%>"/