Tanya Kumari leads the Digital Marketing Classic Informatics, a global web development company.
Short answer; yes. Performance is almost always sacrificed when adding layers of communication between the code you write and the underlying code which eventually executes.
However, the question of why we still use jQuery despite this is a far more interesting question.
So I have been dabbling in a small amount of JQuery recently, as you mentioned it, and so far I must say that I am having mixed feelings about it.
As it says on the tin, JQuery is basically just JavaScipt, but set up so you can do more, faster, and with less code.
I’ve also been told that the largest web companies use it, like Google and Youtube.
To simplify this entire email, basically what I’m asking is does JQuery sacrifice performance and code efficiency?
Thankyou for any help you can provide
The jQuery project began back in 2005, with the intention of simplifying the code required to find HTML elements on a page using CSS selectors.
For small websites and simple web apps, the advantages of jQuery will often outweigh the minimal performance impact.
So why is jQuery so popular anyway? In his email, Ollie poses the question:
“By using jQuery, aren’t you just sacrificing efficiency for ease of coding?”
Yes! But I think I would avoid using the word “just”. Ease of coding is an incredibly important aspect of good software development.
In a larger project, the ability for developers to quickly navigate code, make changes and add functionality translates directly into income for the company and benefits to their users. It also contributes to how happy developers will be working for the company.
The popularity of jQuery is largely due to its simple and consistent API. From the jQuery home page:
[jQuery] makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
The purpose of jQuery is to simplify the code you need to manipulate the elements on a page, and also watch for the events which might trigger those changes. Over time it has evolved to support other common use-cases such as Ajax, which is a way of loading data from an external source.
You may notice that the jQuery download page says “jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8”. When jQuery 2 was released, they decided to stop supporting Internet Explorer versions lower than 9 so that they could simplify their own code and keep jQuery running as quickly as possible in modern browsers. Fewer “if” statements, lighter code!
There are still a few browser bugs which jQuery does take care of for you, and if you’re up for a bit of technical reading then there’s a great document here which lists them all.
Frameworks and libraries exist to enable faster and easier creation of software, but there is not one choice to rule them all. Always make your framework choices based on their strengths, their intended use, and the requirements for the project at hand.
Create your free account to unlock your custom reading experience.