jQuery is a very powerful scripting library. And, just like any other scripting library, it can be used as a web resource in Dynamics CRM. But, there’s a catch.
This following section is copied directly from the SDK, and pay close attention to the red highlighted section:
- Use jQuery with HTML web resources
- We recommend that you use jQuery together with HTML web resources to provide user interfaces because it is an excellent cross-browser library.
With HTML web resources, you control the libraries that are present and there is no restriction against manipulating the DOM. Feel free to use jQuery within your HTML Web resources.
- Avoid using jQuery with form scripts or ribbon commands
- We do not recommend using jQuery in form scripts and ribbon commands.
Most of the benefit provided by jQuery is that it allows for easy cross-browser manipulation of the DOM. This is explicitly unsupported within form scripts and ribbon commands. Restrict your scripts to use the Xrm.Page and Xrm.Utility libraries available in form scripts and ribbon commands. If you decide to use the remaining capabilities of jQuery that are useful with Microsoft Dynamics CRM and include the ability to use $.ajax, consider the following:
For best performance, don’t load jQuery in the page if you do not need it
Using $.ajax to perform requests against the OData and Modern Apps SOAP endpoint is supported, but there are alternatives. The alternative to using $.ajax is to use the browsers XMLHttpRequest object directly. The jQuery $.ajax method is just a wrapper for this object. If you use the native XMLHttpRequest object directly, you do not need to load jQuery.
Each version of jQuery that is loaded in a page can be a different version. Different versions of jQuery have different behaviors and these can cause problems when multiple versions of jQuery are loaded on the same page. There is a technique to mitigate this, but it depends on editing the jQuery library and any other libraries that depend on jQuery. More information: jQuery and jQuery UI with Dynamics CRM 2011 & 2013, jQuery.noConflict()
Use of jQuery
So, to make a long story short, there’s a few alternatives:
You can look at a library called Sparkle XML. For more details see HERE.
You can put the whole jQuery library in a namespace. For an example, see this URL: