2

I am using Angular to add a new feature to an old site that loads a very old version of jQuery.

How can I check if Angular is using that jQuery version? And if it uses the old jQuery version, how could I configure Angular to ignore it and fallback to jqLite?

I am finding some random errors and I would like to rule an incompatibility out before digging any further.

3
  • 1
    you may refer to this SO for answer. stackoverflow.com/questions/23900291/… Commented Aug 22, 2014 at 6:50
  • seems to be a fair question and somebody has voted to close...^^?? Commented Aug 22, 2014 at 7:15
  • Thanks a lot for pointing to that question. I did not find it before. Commented Aug 22, 2014 at 7:16

1 Answer 1

0

This should let you know the version of jQuery used by angular:

angular.element.fn.jquery

Which should be the same as

$.fn.jquery

Which will give you the version of jQuery loaded in the page.

You can revert to jQlite by removing jQuery from the page, but I'm not sure you can easily do it while keeping jQuery on the page as jQlite is private in angular's script. You could edit angular.js to save a reference of jQlite in the global scope, but then you can't use minified angular.

Another option is to include a script with jQlite's source on the page, then use it with angular.element = window.JQLite. Overall though, just removing jQuery from the page would be your best bet, in my opinion.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi, $.fn.jquery returns my jQuery version. angular.element.fn is undefined. Does it mean angular is not loading jQuery. I didn't change anything yet. Removing jQuery is not possible as my angular feature is embeded in a page which needs the original jQuery.
@Esclapes Hmm, it seems that if you include the jQuery script after angular it doesn't use it. I was always under the impression the angular script covers this case. You could try that.
Yes, that seems to be the case. Both scripts are loaded in the head, but jQuery loads later. Thanks for your reply about how to get the version of jQuery.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.