I recently discovered that Kentico has an inbuilt jQuery library (who knew!) and there is a knowledge base article advising how to add Kentico’s jQuery. The article adds a foot note: “Please do not register any other jQuery library on your pages”. This applies to Kentico V6 and V7.
Like most people, I link in the latest version of jQuery directly in the master page (as do Kentico themselves at www.kentico.com) This has proven to be problematic in some instances…
Web parts that use the inbuilt jQuery will load Kentico’s jquery-core.js. One example being the Password Strength web part. jquery-core.js checks if jQuery is loaded already, then if not, loads it in. Then it creates an alias for jQuery as $j and de-links the dollar sign from jQuery using
So why not just comment out
var $j = jQuery.noConflict(); from jquery-core.js? Well, $j is also used by scripts throughout the CMSDesk, which don’t otherwise have jQuery injected into the page. i.e for the Password Strength to work when creating a new user in the CMSDesk.
A simple solution for me was to amend jquery-core.js, removing
var $j = jQuery.noConflict(); then setting $j as an alias for jQuery:
var $j = jQuery. This way $j can be used by web parts and I can continue to use the $ on my pages without error.
It could be argued that I should just use Kentico’s jQuery and use $j instead, but I prefer to have control over the jQuery loaded in my pages, and any programmers amending my code can use jQuery with $ as they’d expect.