Why do I need JQuery again?

So when pasting footers and headers in for example the index.html-file you need to paste a jQuery string to make it work. I cannot remeber why this is. What is it that the JQuery strings do in a document again? :slight_smile:

To make this code below work so that footer is loaded I need to include the JQuery-string. I wonder why that is?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="stylesheet.css">
    <title>Website for chart patterns</title>
</head>
<body>
    <div id="footer"></div>
    <script src='https://code.jquery.com/jquery-3.2.1.min.js'></script>
    <script src="Javascript1.js"></script>

</body>
</html>

If I remove the JQuery string above the JS-file the footer does not load. Why is that? WTF is JQuery? :slight_smile: :slight_smile:

Hi,

Jquery is a library of javascript functions that can make your coding life easier. You can work without it, but then you need to write more code and may not be as reliable, or you can use other libraries.

The footer is a div, it has no direct connection with javascript or jquery, it is simple html. So what do you mean with ‘it does not load’ ? Is it created by javascript or is its content created by javascript? If so, it won’t load if you’ve used jquery to create that content. (jquery functions begin with a $(’.selector’).on(‘click’, function) . Are you seeing such functions?

Greets,
Karin

JQuery adds magic to Javascript. JQuery uses normally fewer lines of code and many use it because it simplify Javascript. On the other hand JQuery adds extra load time (loading many lines of unused? Javascript) and adds security issues as well. Jquery : Security vulnerabilities, CVEs

I think you can find many Javascript vs JQuery out there, but I have found none that actually helps me chose.

My view is that I do not want to learn another framework. I use vanilla Javascript despite some extra rows of code. At the end of the day it maybe save some seconds.

The security angle is a red herring: 8 CVE’s for jquery, none over a 5, going back to 2007 with the last one being nearly 2 years ago is pretty damn good. Especially when the last one looks to be really a Drupal vulnerability from misusing the library. All dependencies introduce a security risk, but jQuery is not inherently risky.

What it is however is pretty much obsolete: its selector syntax is now incorporated into current JS versions, and its Promises implementation is unfixably broken, so the last thing it has going for it is the way it can auto-map functions over multiple matches of a selector. But most of all, the problem is that jQuery is an imperative library in what’s now a world of declarative component frameworks. It can’t even see the DOM of components without special integration hooks, and even then it’s still more cumbersome and slower than the framework.

The lessons barely use jQuery beyond its selectors, class assignment, and simple event binding. We really should stop teaching it.

4 Likes

The footer is a div, it has no direct connection with javascript or jquery, it is simple html. So what do you mean with ‘it does not load’ ? Is it created by javascript or is its content created by javascript? If so, it won’t load if you’ve used jquery to create that content. (jquery functions begin with a $(’.selector’).on(‘click’, function) . Are you seeing such functions?

Right, this would help us answer the OP’s question. I would assume that there is something in “Javascript1.js” that needs jQ. If you open up your console, there are probably errors related to it.

Not wanting to delve too deep into the jQ debate, I think it’s good to learn the basics. As pointed out, it is largely obsolete now, but still shows up occasionally, especially in legacy code. So, learn the basics, but you don’t need to go too deep unless you’ll be working on jQ code. Whether or not FCC should stop teaching it, I’m kind of on the fence about it. Maybe it should be an optional thing, idk.

My view is that I do not want to learn another framework.

I would add the words “unless you have to”. There are many great interface libraries out there. I love React. I think without something like that, it is easier to build and maintain large sites. Just like in the days when jQ was king, JS is slowly catching up, but I don’t think it is quite there yet. And most of the jobs ads I saw the last time I looked for a job were asking for some kind of library/framework. Just my $0.02.

1 Like

I agree with all of what has been said.

I think the idea is that everything in the current curriculum will still be available, even once the new version is completely rolled out. I am sure I read mention of this.

As it stands, I would say the jQuery stuff is optional… you do not need it for the certificates.

True. I but perhaps it’s a bit jumbled. I’ve been wondering if I should start a discussion about how our things are organized. I think sometimes it’s confusing.

I did not mean framework as a phenomenon. Just JQuery in this case. But the same apply on ORM “frameworks”. They add magic to SQL but creates often a complexity out of fake simplicity and deliver basically a complete different language upon the “pure” language (like JQuery does). Passing through another layer also slows down and adds extra dead meat.

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