Is it really needed?

Anyone know what this code is all about please? How necessary is it?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>

Are you using jQuery?

Unless you have a boss telling you otherwise, jQuery isn’t necessary at all. Everything it can do can be written in “plain” JavaScript.

It is a link to the jquery code online which saves you downloading it to your server. As has been said if you are not using Jquery you do not need it

If there is any scripting that uses the dollar symbol, such as $(“document”) then it is needed.

No one can tell you whether jQuery is a necessary dependency without more details about the project and platform. If you are working with any type of open source CMS than chances are jQuery is a necessary dependency.

Thank you all very much for the input. (How do I know if I’m using jquery or not?). In fact, I have just realised that it’s mentioned TWICE on every page of the site, once in the head and once in the body.

Also, there’s these two lines on every page in the body:

<script type="text/javascript" src="/js/jquery-ui.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.1/jquery.validate.min.js"></script>

Those two lines tell you that jQuery is being made available to each page. It doesn’t tell you whether they’re being used though. You’d need to look in the other JavaScript files that are being linked to on the page.

If it is being used, there will be code that starts with a dollar sign (or jQuery) and parenthesis, such as:

jQuery(function ($) {
  // code in here
});

There’s loads of dollar signs within the coding on every page, but the only times jquery has been mentioned is for the ones already mentioned here.

It sounds like it’s being used quite extensively then. You won’t (usually) find any mention of the term “jQuery” where it’s being used - the dollar sign is how it’s referenced.

If you are not sure comment out the two lines and see what happens - simple

5 Likes

Thank you for the replies. I will comment out and see what doesn’t work.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.