Kentico 8 usage of jQuery

Sietse Trommelen asked on April 23, 2014 09:43

Hello Kentico 8 users,

Today I've started working with Kentico 8. However, I've come across a problem that has to do with jQuery files. I know that Kentico has a built-in jQuery library, but I want to use a different jQuery version (1.11.0). In Kentico 7, it was possible to override the built-in jQuery by defining the new jQuery library in the header of the master page. This, however, is not possible in Kentico 8. It seems that the built-in jQuery module is being loaded after the scripts in the header of a page have been loaded.

I'm using a workaround right now and that works perfectly. The workaround is to add a JavaScript web part to your master page, reference the jQuery library, uncheck 'include jQuery' and set 'Linked file page location' to 'Startup script'. This seems like a dirty solution, but it works.

Does anyone know of a better solution? I have tried using jQuery in noConflict mode, but that does not work.

Correct Answer

Brenden Kehren answered on April 23, 2014 14:12

To fully perform your check, you need to be logged out of the Admin interface. By default Kentico will load their custom jQuery library as long as you are logged into the Admin UI because the UI depends on it. If you are logged out, there will be no javascript or jQuery libraries loaded by "default".

I use the javascript webparts and have no problems. While in the Admin interface, the javascript webparts don't load the script unless you are in preview mode, very helpful to avoid all the errors and issues.

You might also check this post out for some conversations on the same thing

0 votesVote for this answer Unmark Correct answer

Recent Answers


David Komárek answered on June 25, 2014 02:32 (last edited on June 25, 2014 04:30)

Please consider voting for the following idea, which should help avoiding jQuery conflicts in future releases: ideas.kentico.com/forums/239189-kentico-product-ideas/suggestions/6096405-kentico-should-use-its-own-alias-for-jquery

0 votesVote for this answer Mark as a Correct answer

Heska IT answered on July 23, 2014 23:51

Brenden,

I understand what you said about the default Kentico library loading if you are logged in. This is an issue for us though because we have customers that log in to see their accounts and they are not seeing the jQuery we have set up referencing a newer library properly. When logged out they see it right obviously. I have been playing around with the jQuery no conflict solution and mitigate but the default library still loads. We would like this to show up right whether a user is logged in or not. Any suggestions?

0 votesVote for this answer Mark as a Correct answer

David Komárek answered on October 2, 2014 10:15 (last edited on October 2, 2014 10:15)

Michelle,

there are some improvements already in Kentico 8.1, which are discussed in this article. We have changed our jQuery to use "$cmsj" alias we are not using "$" any more. Also the article describes how to make Kentico not load its own jQuery into the "jQuery" alias either. Therefore, both "$" and "jQuery" can be reserved for your own jQuery.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.