We are migrating our environment from AEM 6.2 to AEM 6.4. We have observed that aem jquery (1.12.4-aem) is overriding our custom/updated jquery library and because of this most of the functionality is breaking. Please see the screenshot below:
Note: It only happens in Author environment. In publish environment, AEM jquery doesn't load.
I have found solution suggested for AEM 6.0 here How to resolve jQuery library conflicts in AEM 6? According to the suggested solution, we will have to add granite.jquery.noconflict" as a dependencies on "/libs/foundation/clientlibs/jquery". If this is the suggested solution, then what is the correct approach to push this changes through code.
We have not added cq.jquery as a "dependencies" or "embed" in any of our clientlibrary. Its default behaviour of aem to load aem-jquery to keep the internal functionality working. It happens in any version of AEM. But none of aem version having jquery conflict issue except aem6.0.
Unfortunately, we have the same issue in aem 6.4 again.
If you want to reproduce this, please follow below steps.
1) create a template and load your custom jquery library at template level.
2) create a page based on the above template and open it in editor mode.
3) Open the browser console and run the "$().jquery" to check the final loaded version of jquery. [It will ensure which jquery (aem-jquery or custom-jquery) is loaded last]. Please see below screen shot :
Note: you can see both jquery (cq.jquery and your-custom-jquery) is loading in network tab. (please see screenshot below)
AEM loads "cq.jquery" library in author mode for internal AEM functionality from below path:
I tried by removing the "cq.jquery" categories to stop the loading of aem jquery. Then i could see my custom version of library without any conflict. But AEM functionality stops working. Ex: http://<domain:port>/Siteadmin was not getting opened and showing blank.
I want aem to load jquery for internal functionality but it should not override our custom jquery. We don't have such issue in aem 6.2 though aem is loading cq jquery in aem6.2 but not overriding the custom jquery.