开发者

JQuery over JavaScript Why and When to use? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. 开发者_JAVA百科

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 5 years ago.

Improve this question

I'm a student and also new to JQuery. I want to know the difference between JQuery vs JScript. How we decide what to use and when to use those two technology.

Considering

  1. Performance
  2. Technology


jQuery is JavaScript. It is a JavaScript library, so it operates on top of JavaScript. It cannot exist on its own, so you can't use one over the other. You can use just JavaScript or JavaScript and jQuery.

jQuery is designed to make many JavaScript development tasks much easier.

Use jQuery when it will significantly reduce your development time, and you can afford the extra overhead of downloading the library.

A lot of people automatically include jQuery without considering the fact that it might not make the particular development task at hand much easier. This is a bad habit to get into...

Personally my most common uses are:

  • Complex element selection
  • Animation
  • Event handling

There is a humorous Photoshopped screen shot of a "Stack Overflow" post that pokes some fun at the overuse of jQuery. Enjoy:

JQuery over JavaScript Why and When to use? [closed]


I was initially against jQuery and, for new programmers, I still am. It is a pure JavaScript framework that has several benefits; here are some of the major ones:

  • crossbrowser support
  • easy element selection
  • customizable plugins
  • large support community
  • very popular

Some would argue that it is large, which could affect your web performance... and they would be right. However, because of its popularity, it is likely to have already been used on some site you've visited before. Most browsers these days are good about caching scripts/images, so that download hit is reduced over time.

On the other hand, many new programmers that rely on the framework become very dependent on it, so much so that they lose their ability to evaluate the best tool for the job, and use the most familiar tool that they're used to. These same programmers lose their ability to properly debug and become reliant on an API that has no standard.

What I like using it for is it's cross browser support, which is great for event handling; and whenever you apply dynamic styling to elements on the page (or really anything that requires you needing a more advanced set of elements). Element selection is it's #1 tool, where you can select elements by id, type, attribute, classname, tagname, hierarchical relationship,... all sorts of ways.


I want to know the difference between JQuery vs JScript.

JavaScript is a scripting language for the web. Microsoft refers to their implementation of it as "JScript" but in terms of syntax it's pretty much the same.

jQuery is a software library, written in JavaScript, whose intention is to help JavaScript developers when writing code that is to be run in a web page.

How we decide what to use and when to use those two technology.

JavaScript (including jQuery) can be used to add interactivity to a web page beyond that which is possible merely with HTML and CSS. This allows for a more "application-like" experience for the user. Many see it as a bad idea to make a web page which depends on JavaScript, and won't run without it, and insist that JavaScript should only enhance the user experience. However, websites which won't work without JavaScript do exist and are becoming more common.

jQuery runs in JavaScript, and is written in JavaScript. If you are writing JavaScript for a web page, it is often a good idea to also use a library (or framework) like jQuery to make the task of browser-compatibility that much easier. It is like a pre-packaged set of JavaScript routines that you may have otherwise needed to write yourself, packaged in an easy-to-use way.

A drawback of using jQuery is that it is a relatively large file size, which does matter on the web. Some would argue that if you are not using enough of jQuery to justify its file size on your site, you should consider something else (such as a more modular framework, or not using a library/framework at all).


It's perhaps a little redundant now but 'JScript' was originally the name of the Microsoft implementation of Javascript in old versions of Internet Explorer. Thankfully it's long since disappeared although if you find references to it in older literature just replace with 'Javascript'.

Back to the questions, if you're new to this, I'd strongly recommend going for JQuery (or another Javascript library) instead of raw Javascript. You can do very complex things with one line of JQuery that would take a lot of coding and debugging if you were to use raw Javascript. Ultimately you will need an understanding of the underlying language to take full advantage of JQuery but if you want something you can deploy today, start with JQuery rather than Javascript.


I have been recently struggling with the same question, jQuery or JavaScript. Coming from a coding background that includes several old school programming languages (C, perl, ksh, and more recently Java and C#), I am finding that JavaScript is MUCH easier to quickly understand than jQuery. From a support perspective, the ease of understanding the code is more important than less typing when creating the code. The one answer here, that does have me reconsidering the use of jQuery, is browser compatibility. This one significantly impacts future application support. Based on my experience (over 20 years as a software engineer) the application life cycle spends a lot more time in support than it does in development.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜