1 Reply Latest reply on Jan 26, 2012 5:58 PM by justin_at_adobe

    question - best practive to extend standard js in the CQ

    kasq Level 3

      Hi all ,


      I have question about best practice to extend standard widgets js files in the CQ. At this moment we copy for example SideAdmin.Actions.js from libs folder to apps folder and we customize there a file.

      In this situation we don't customize standard js file.


      The problem is that when new version of CQ will be released, there can be situation in which the SideAdmin.Actions.js file will be overwritten by new version of this file in libs,

      so it means that we need also change our custom version of this file in the apps. Maybe there is other possible way or some best practice to create a custom version of js file in the CQ.




        • 1. Re: question - best practive to extend standard js in the CQ
          justin_at_adobe Adobe Employee

          Hi kasq-

          It can depend slightly upon what you are trying to extend and how, but in general, what you should do is create a new CQ client library with the category cq.widgets. In this client library, include some JavaScript files. In these files, make whatever changes you need to make to the out of the box objects. Or create your own objects/classes.


          For example, you mentioned SiteAdmin.Actions.js. So let's assume you want to create a new action. In your custom client library, have a JavaScript file which does:


          CQ.wcm.SiteAdmin.myCustomAction = function() {

            //do something here



          Replacing or removing an existing action would also be possible.


          There are times, especially with the widget classes, where you may need to replace the file entirely. But I'd suggest trying to avoid this and instead try to write custom widgets which extend the out of the box widgets.