2

I am creating a custom control and had a thought before I began. My control relies on the jQuery library to work. What if the user already has a version of the library already on their page. Will this effect anything? If my version is newer / older and my control will only work with that version of the libaray, what should I do? Thanks

1 Answer 1

3

Well, you could check in your scripts your control is rendering if the jQuery function is defined.

if (typeof jQuery == 'undefined') {  
  someLoadMethodJustForExample("jquery");
}

If not, it isn't loaded. And you should load it.

If there's already another version loaded jQuery.fn.jquery; will return you a version string like "1.4.4". So you could display an error message and tell the person to reference another jQuery version which is compatible with your control or just let your control do the work.

Google does have a dynamic loading function for jQuery (and a lot of other frameworks) you could use.

google.load("jquery", "1.4.4");

Hope that helps.

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

1 Comment

This worked out great. I was able to run the google load if jquery was not on the page. Thanks!!!!!

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.