Is it really needed?


#1

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>


#2

Are you using jQuery?


#3

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


#4

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


#5

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


#6

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.


#7

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>

#8

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.


#9

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
});

#10

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.


#11

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.


#12

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


#13

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


#14

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