开发者

OK, so JQuery is cool and all but is it really wise to use it in your project? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or exp开发者_如何学Goertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 12 years ago.

I am new to web development, learning ASP.NET. I used some JQuery script so am just wondering if it causes some performance issues or anything like that. Is it OK and rather safe to use it?


I work as a Developer Evangelist for Microsoft, and as the others have said jQuery is not only stable and safe... it's also awesome.

If it wasn't, we wouldn't have baked it into the .NET project templates.

In terms of performance there are things that you as a developer can do wrong, but if you follow best practices jQuery will improve your visitor’s experience, not detract from it.

If you are learning jQuery then make sure you visit jQuery.com to look at their getting started section. Also I found the following links useful:

  • Get Started With JQuery

  • Improve your jQuery - 25 excellent tips

As well as the Google CDN, Microsoft also provides one: http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js

Ajax CDN Announcement

Microsoft Ajax CDN Documentation


I feel like I am being baited...

jQuery is an amazing library. The fact that it aligns how CSS and JavaScript are selected and processed is amazing. The fact that it hides so much of the browser-to-browser inconsistency that makes JavaScript such a pain is huge. The fact that it makes so many amazing things simple is...well...pretty valuable.

If you cache properly and call it from a CDN* there is really very little performance issue. In fact, I would say that my sites are a good deal faster because of jQuery since the jQuery code I am calling is much better than I would do myself.

Also, I try for Unobtrusive JavaScript wherever possible so the site still at least works even if the JQuery magic is unavailable.

A CDN is a Content Delivery Network. This is the way I recommend you link to jQuery in your pages.

jQuery is available from the Google CDN here:

https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js

If you leave off the minor version number, Google provides the latest version.


It's safe to use and saves you a lot of time since it gives you the same api for all browsers.


It's safer to use it. Different browsers do things differently, jQuery provides a wonderful abstraction layer. You can essentially trust jQuery to do the required plumbing to work on each supported browser, rather than you having to take care of it yourself.

There technically would be a slight overhead since you're hopping through a method to get to the end result, but it's so tiny I would not worry about it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜