Hot answers tagged

113

First off - it's impossible to use jQuery only, all jQuery does is add a $ object to your global scope, with a bunch of methods in it. Even more manipulative libraries like prototype aren't an alternative to javascript, they're a toolbelt to solve common problems. The main advantages to adding jQuery to your toolbelt would be: browser compatibility - doing ...


89

Let's talk about cars. Oh wait, we already did - remember that time we met, some time ago? We talked about cars. In fact, you seemed to be quite the expert on cars. You were able to explain, in detail, all of what's right, wrong, and exciting about the latest Formula 1 race. You knew by heart all of Lamborghini's models, including their price and ...


54

To answer that question, I'm going to ask you a rhetorical question about another structure that have similar property to the DOM elements that jQuery manipulates, that is the good old iterator. The question is: How many operation do you need on a simple iterator? The question can be answered easily by looking at any Iterator API in a given language. You ...


49

Stop using buzzwords and try making strong arguments instead. Even the Wikipedia page for Unobtrusive JavaScript says that the term isn't formally defined. It may be a blanket term for a number of good ideas, but if it sounds like a mere fad or fashion your boss and coworkers won't pay a lot of attention. Worse, if you keep going on about something they view ...


35

Start your for loops where ever you have to start them. The reason a lot of for loops start at 0 is because they're looping over arrays, and in most languages (including JavaScript) arrays start at index 0.


35

JavaScript certification is called github. It's called write modules, maintain modules, and share modules with the community, build popularity, etc. As a JavaScript employer I couldn't care less what certification you have, I care about either examples of github modules showing quality code or live websites/web applications show high quality code.


35

There is no way to avoid that. They are coupled because they interact with each other. If your javascript intends on doing any kind of DOM manipulation, then it needs a way to reference the DOM. There are various conventions for it. The Level 2 DOM API provides the getElementById, getElementByTagName, and getElementsByName methods. To this day these are ...


30

Today, in our work as in our life, it is more important know how to find information rather than know the information itself. I mean that a good developer is a person able to find documentation, network, and that share with an open mind. I am an experienced .NET developer and, believe me, for every project I work on I have to learn new things about the ...


29

Never expose direct access to your database from the web layer. You can never lock that down; someone will send "DROP TABLE table" to your server, however much you lock down the JS source. All they have to do is see what the browser sends to your server to detect that your server accepts arbitrary SQL commands. Not that you can lock down the JS code; it is ...


27

It's more important to study the language than it is to study the framework. Learn the language well, and you'll use the framework well. In order of importance (most important first): Fundamental programming principles - Algorithms, data structures, etc. Language paradigms - OOP, Functional, etc. Language features. Syntax and frameworks.


20

You should upgrade with each release of jQuery -- just take a peek at the update logs before updating. The jQuery team is very good about documenting API changes and deprecated calls. At this point, the vast majority of the API is quite stable and probably won't change. Most changes are behind-the-scenes bug fixes that do not affect the outward API. This ...


19

Update your version of jQuery if and only if you need some new feature that's included in the new version. Simple as that. If you frequently develop using jQuery, keep an eye on the official blog to know when updates are released and what they offer. Wait a couple of weeks or so before upgrading to the latest version to make sure any unexpected bugs get ...


19

2072-rated chess player here. I made this website in pure JavaScript over a weekend. It's not a chess engine (I designed it to create entertaining opening positions as sort of a perverse Chess960 engine), but it's a starting point. The source code is here. There are a lot of complications involved in making a functional board. These include: First, ...


19

No - the $ function is actually only overloaded for three tasks. Everything else are child functions that just use it as a namespace.


17

Mission and philosophy: jQuery set out to make DOM manipulation easier to use, and had a single minded focus on achieving that goal. Other frameworks like Mootools and Dojo focused on making it easier to create complex applications, an idea that was ahead of its time (in 2007), and split the attention of the community and created unnecessary complexity for ...


17

There are advantages, but it's debatable whether they really outweigh the drawbacks. The main one is that you save bandwidth and gain faster responses. jQuery adds another ~30kb to your response. On some networks (and in some countries), that could mean a few more milliseconds. On the other hand, though, you can set up caching for it rather easily using ...


16

Actually, what you're describing exists already for years. It's called caching. And it's available not only for JQuery, but for everything your browser may download. Then sites could check "local" first, before CDN, before finally defaulting to downloading from the website server itself. This is exactly what every browser does. It checks local cache ...


15

There's no technological reason why they couldn't. However, it's not necessary and it's against the web's fundamental philosophy. It's not necessary, because you can achieve almost the same thing with a far future expires header. It's against the web's philosophy because it causes there to be a top-down, centralized authority on which libraries should/...


15

First of all, we have to get something straight: Javascript and jQuery are not two completely different things: jQuery is a Javascript library. jQuery: jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML. Javascript: JavaScript (JS) is an interpreted computer programming language. As part of web ...


14

People like being black and white. If you're going to use a cross browser normalization tool then use it. Don't use it to normalize some things but not others. Example var a = $("#foo"); var b = document.getElementById("bar"); Those two should not be mixed. Either you use jQuery for edge case bugs you might care about or you use the DOM for speed, but ...


14

For web apps, yes, I think it's okay to require JavaScript because it's the nature of web apps to provide a rich, interactive user interface. More simple websites like blogs, portfolios or brand websites should be able to work without JavaScript, in my opinion. I make all my websites work without JavaScript. I know a few people who disabled JavaScript or ...


14

The problem with "chess program" as a concept is that there are many pieces which can absorb a lot of time, and not necessarily interest you at the moment. You can spend years just working on graphics, or an alpha-beta search, or a visualization to help develop for the search engine, or... well, there are lots of pieces. I recommend finding an open source ...


14

As far as I know there are really only two advantages of using vanilla javascript versus a library such as JQuery, MooTools, etc. Libraries have a payload that eats bandwidth. But as people already have pointed out in the other answers you can limit this with gzipping and caching. If you only want a subset of jQuery you can do with SizzleJS and with ...


12

I suggest you to read this article which I think explains pretty well why extending objects is a bad idea, with regard to Prototype also. In summary: Lack of specification Exposure of "prototype objects" is not part of any specification. [...] In order for implementation to conform to DOM Level 2 fully, there's no need to expose those global Node, ...


12

No, jQuery does not kill JavaScript, rather it unfolds the language. There's Nodejs, that uses Javascript as cli or for server-side scripting. About jQuery. I was programming with DOM APIs since 2001 and can assure you that a simple and well-tested DOM API like jQuery lets you work more on the real problem rather than on the API. I also manipulated DOM in ...


12

Reasons I know: When the need is extremely minimal, say 1 onclick. When download speed is critical and the jQuery library is too large AND you don't have to write much (custom) code to replace it. When integrating with other technologies, sometimes raw js is better. When working on a legacy system (aka 'production') already written in js with established ...


12

To really give an exact answer to your question: Yes. Although JQueryMobile is meant for web applications (as pointed out by Yannis Rizos), you can use Phonegap to create native applications with JQuerymobile. What Phonegap does, is create a native app with a webkit browser embedded. So it still is kind of a web application, but also kind of a native app, ...


12

Learn the DOM. By doing that, you will have a better understanding and appreciation for what libraries like jQuery do for you. This also means you'll be better suited in the long run if you must change tools. The DOM will always be there, and is common ground for understanding the fundamental design choices for any given library that interacts with the DOM. ...


12

Only Test if it Brings Value I don't test typically, but if I did I certainly wouldn't aim for any percentage number of coverage or loading tests in front of everything I wrote but rather focus on handling of things I don't control and things that were coded poorly that I don't have time to rewrite. If behavior of things I do control and that I did in ...


12

You can't. Let me rephrase: Impossible You could/should make it harder to use a token. Implementing a max-usage per token, a max life-time, ... It is however impossible to know if it is the scriptkiddie or your 'application' contacting your api. A lot of people tend to forget that it is never the aplpication calling the api, it's the application, telling ...


Only top voted, non community-wiki answers of a minimum length are eligible