I have been using Kendo UI in web resources for Dynamics CRM for several years. My components require the use of ClientGlobalContext.js.aspx. In version 9.0.2.54 of Dynamics 365 online, I found that the newer version of ClientGlobalContext.js.aspx loads its own version of jQuery without checking to see if one is already present. It does this with a document.write statement, so this version of jQuery is always loaded after my code. I can work around this temporarily by using the JavaScript produced by this call with the jQuery load line commented out, since most of the instance/context specific information comes from the xhr request that is part of this page, but I am looking for a supported solution that will upgrade without issue and work across instances. These are the options that I’ve thought of, I am looking for suggestions as to which is the best and any additional guidance on that option. I’ve considered the following:
Wait for ClientGlobalContext to be available then test for jQuery, use a document.write to include it if it is not there (won’t be with some versions, and they could stop including it at any time), once jQuery is available, load Kendo and proceed with my page. Again, I don’t have a way to change the Microsoft page and since there are asynchronous calls there, this may leave me with a timer loop—I can’t see how this isn’t ugly, but I may be missing something, and ugly or not it may be the best option.
Convince Microsoft to check for jQuery before reloading it or to provide an alternate supported file without the jQuery. Since I haven’t seen anyone else expressing this frustration, I am not thinking this is likely. Not currently an idea on the Dynamics 365 forum, this was Telerik's suggestion, but is this a reasonable expectation?
- Move away from jQuery-based UI libraries since I will never control the whole page in Dynamics 365. Very painful, since I know and like the current library and the jQuery version has features I use that are not yet in the Angular version (Kendo Angular version would be the easiest migration even given that I would have to learn angular). I know this is subjective and not technical, so I can delete this option if it makes the question better, but it is an option and will be harder farther into the project.
- Another solution I haven’t thought of, keeping in mind that Dynamics web resources function completely client side. I am writing in TypeScript and using npm modules and Webpack if that is helpful
The use of jQuery is supported and recommended (in some circumstances).
I don't think its unreasonable to raise it with Microsoft to get some help. That said it may not be that helpful;
It would probably be quicker and save you time, to just implement a fix in your own code.
A solution you may want to consider (mentioned in the article above) is using
jQuery.noConflict
. Scott Durow presented a solution to a similar problem here.In regards to supportability and future upgrades. It's worth remembering what staying supported means.
The first article I linked above and this, frame the context in which jQuery is supported, but don't cover the specifics of this situation. I would suggest that any coded solution you implement will probably upgrade without issue. That said testing and validation is recommended by Microsoft before upgrading production.