Jquery Vs Mootools which is having good performance? why? - javascript

Can any one reply me which of the javascript frameworks are better to implement on my project?
jQuery or Mootools?

MooTools has the better API and once you actually use it, you'll see how the design choices make sense.
Try them both, but you'll stay for the extendability of MooTools

It's a matter of what coding style do you prefer and can help you in the long term. Just because other people use jQuery doesn't make it any easier for me to learn the way that it's coded.
This is a must for you to read before you go any further: http://jqueryvsmootools.com/

In the last performance comparison I know of, jQuery beat MooTools on IE, and they were head to head otherwise. Of course, one year is a huge lot of time in Javascript, so that says little about their current speed.
Anyway, unless you are really sure Javascript framework performance will be important for you, I would recommend jQuery, which has clearly been the popularity winner (see eg. Google Trends), which means better community support, more eyes and more developers in the long term.

Go with JQuery, it has the most active development community. Even MS is contributing code to the Jquery project.

Related

MooTools and JQuery Side by Side

I just inherited some web pages which uses MooTools. I never used MooTools. Now I need to add some functions on the page, I wonder if it's a good idea to use jquery and mooTools on the same page?
Basically, I have 3 options,
Convert the pages to JQuery, which I have to learn MooTools to do that.
Write new functions in MooTools. I have to learn even more MooTools to achieve this.
Use both on the page.
Your opinion will be appreciated.
Opinion: Learn MooTools and then move on with it. Sounds like a great opportunity to learn something new. Why introduce an entirely new library with addition js bloat if you don't need to. If it'll solve the problem you're golden.
MooTools is a perfectly solid and acceptable Javascript library and I'd recommend you add it to your list of known technologies rather than tear it out and replace with JQuery. Mixing the two is not a good idea as you're likely to encounter obscure difficult to debug conflicts.
JQuery has had all the press of late, but it's by no means cut and dried that it beats every other library hands-down. Far from it. You might even find you prefer MooTools :-)
ADDED: For what it's worth my personal experience is that MooTools seems to play alongside other javascript code more nicely than jQuery. I've been handling several sites of late which have mixed in MooTools with various other pieces of Javascript for different effects/functionality and it's all seemed to play along together with minimal issues. OTOH pages that use jQuery tend to use jQuery versions of everything. YMMV of course.
Personally, I'd recommend not using both, as there are strange conflicts, even with jQuery.noConflict(). Go with one or the other.
If you do end up using both, be sure to use jQuery.noConflict() to ensure that using the $ doesn't conflict.
Using jQuery with Other Libraries
i'd say, depends on how the code is structured and what you need to do. mootools does render itself to easy refactoring and extending (this is, after all, partly the reason it exists) but it takes a while to figure best practices and so forth.
however, your learning curve from vanilla javascript or jquery won't be too steep, especially so if all you care about is DOM mantipulation, event handling and effects. things get more interesting when you decide to write / extend mootools classes and venture into prototyping - but you may not have to do that...
there are some pretty good tutorials around for most things as well as some demos on doing things through jquery and mootools (equivalent ones). http://jqueryvsmootools.com/ is a good example on how the same task can be done through either one, i'd recommend reading it before deciding.
whatever you decide, it is a bad practice to use two frameworks (when you can do without).
It depends on how big a project it would be to convert to jQuery, how much of your job is maintaing these pages (vs other pages that already use jQuery), what the urgency is for your first set of changes, etc...
It comes down to a cost comparison: how does the cost to your business to convert them to jQuery compare to the cost to the business for you to learn mooTools (and maybe keep both mootools and jquery in your head at the same time).
The only thing I can say for sure is don't do option 3. This isn't necessarily because it you can't make it work (and there will be challenges), but because you'll have to learn mootools to properly maintain the pages anyway. Once you do that, you may as well just keep them mootools rather than re-write everything or try to mix frameworks.
Personally I'm inclined to say convert it jQuery, since I believe jQuery is eventually going to corner the market. The implication then is that it will convert to jQuery at some point, and so the long term costs to business are probably best optimized by doing the conversion earlier while there's less to convert and mootools is still relevant so you can easily get help with the conversion. But that's certainly arguable.
jQuery and Mootools basics are close enough that moving from one to the other isn't much of a headache.
Whenever I'm given the choice between the two, I lean towards Mootools - especially if I'm intending to do any sort of effects or animations. Mootools's base FX libraries are far more robust and generate better results cross-browser in my experience.
Like others have suggested, you could take this opportunity as a learning experience. If you're satisfied with jQuery and don't feel the need to learn another framework, port the code over. You can't really go wrong with either in the end.
Since you're more comfortable with jQuery, I would just call jQuery.noConflict(); first thing, and write the functions in jQuery. That is, of course, if time is a factor.
There is a project that twists and prods Mootools to make it look like JQuery (a wolf in a sheep's clothing... or a golden coin painted to look like silver...)
I certainly think you should learn Mootools, but that might help.
I agree with those that are in favor of learning mootols, but i think that is even better if your take that decision because you finally think that learning mootools worth it.
So i think it would be nice to have some research over mootools capabilities.
I like this articule about this subject. And I think it can be useful for those reading this thread.
http://jqueryvsmootools.com/index.html

Can I learn how to use jQuery with just a basic JavaScript experience?

The question is: Is it bad to learn how to do special effects, table sorting, etc, using jQuery instead of learning the bits of code that bring that alive with pure javascript?
I have previously addressed a similar problem in a question, but I missed adding this extra inquiry!
Yes you can. Doing it in JQuery isn't bad. Everyone uses some sort of Javascript library. I love JQuery. Your odds of making things that work in all browsers go up quite a bit, you get the UI done quicker, etc.
Though having a bit of Javascript knowledge is good, because when things go wrong you want to be able to debug the problem.
JQuery.com has lots of good tutorials.
You really should use jQuery; it will allow you to spend more time adding features instead of trying to make your code work in every browser (Note that even jQuery is not a silver bullet; you'll still have some cross-browser headaches in any non-trivial web app, especially if you need to support IE6).
There's no point in turning your back on new tools and libraries just to "stay close to the metal".
If you're afraid of lowering your value in your boss' eyes, look at it a different way. Would you prefer to hire a programmer who spends all of his time working around browser bugs, or a programmer who uses jQuery and finishes his projects faster because of it? Remember that managers are trying to ship products and make money, not simply hire elite programmers.
Personally I was recommended to learn JS before learning jQuery. But started off with jQuery, and can make pretty much with it without to much JS experience. What you do need to know of JS you can just google it and learn it when needed ;)
jQuery is fantastic for us that doesn't take the time to learn everything about JS
Personally, until the beginning of this year, I used to limit my use of javascript to only helping aid the user with things like web forms.
However, after playing around with jQuery for no more than a few days, I realised how much easier it made achieving javascript effects and functionality. Now I pretty much use jQuery on most web pages, a lot of the time, just to add nicer UI effects.
A background knowledge of raw javascript will never go amiss and you will almost certainly still have to mix it in with your jQuery scripts, but when you run into troubles, nearly every problem I've had, had a solution already posted on Stack Overflow or just on Google.
Not a very technical answer, but as an intermediate programmer, and javascript newbie I've had no problems learning to work with jQuery. The documentation and community are very helpful.
I think you should set yourself a goal of knowing javascript well enough to be able to author a plugin if you need it in your favorite framework. While using a framework is almost always the right way to go, there will be times when you can't find a plugin that does exactly what you need. At that point you need to know javascript well enough to be able to adapt a plugin to your needs or write your own.

Do javascript developers need to know jquery?

If you were to hire a javascript developer would you expect them to know jquery?
I just started using stack overflow this week and knew that jquery led the pack, but didn't realize the extent of it until I noticed that MooTools (my favorite) has 59 questions while jquery has over 4000. (of course, a good statistician could attribute jquery having more questions to it's usability, rather than it's popularity--but we know that's false)
And then I started noticing that many people post questions with the tag "javascript" but not "jquery" when every line of their code is jquery--like it's the de facto javascript 2.0, or that they don't even realize they aren't writing "javascript" but rather jquery.
Anyway, I ask this because I've always been freelance and could use whatever framework I want on a project. But lately I've been recommended to be the front-end developer for a couple companies. I want a feel for the community's expectations to know if I should put some other personal projects on hold to pick up jquery before exploring the positions that might be offered.
No. I'd expect them to know how JS works. A good JS developer will pick up jQuery in less than a week, probably a few hours.
A developer who knows jQuery but doesn't know JS has a great deal to learn and would only be considered for the most junior roles.
jQuery is definitely not JS2.0 - it's a great standardisation framework if you still need to target IE8 and the like, but it's not great at mobile, it can't be loaded with async or defer, it doesn't support newer features like passive events, and its primary optimisations are about finding elements in an already built DOM (which means it doesn't add much value for client side DOM builders).
I would expect them to have heard of it, and be able to talk about its strengths and weaknesses against other frameworks.
They should at least know what JQuery is, and be able to tell why they chose it or another framework. Next to that, a basic understanding of the most popular javascript framework can never hurt.
I started off when I came across mootools and have not looked back since. But recently, I have spent a fair amount of time polishing my 'vanilla' javascript and have also started looking at jquery (out of sheer curiosity ). Turns out, you need to understand a lot about the frameworks, the differences between them and how javascript works if you want to be able to translate your skills and be able to refactor code between them freely.
for example, consider this as the logical code refactoring between the 2 frameworks
mootools
$("elementId").addEvent("click", function() {
this.setStyles({
border: "1px solid #000"
});
});
jquery
$("elementId").click(function() {
this.css({
border: "1px solid #000"
}); // fails.
});
I was surprised to discover jquery did not work - and then considered that mootools extends the elements' prototypes by adding .setStyles whereas jquery is function based. the fix is obviously to use $(this).css instead - only it's not that obvious at first. It made me realise it would take more than reading the interface docs to be able to swap between the two.
as somebody said, it would take a week to pickup on all of the nuances of jquery even if you have a strong-ish javascript/mootools (or other framework) background, but it won't be such a challenge. moving from jquery over to mootools, however - won't be such an easy task if you are not well versed in vanilla javascript and OOP.
the short answer is, I wouldn't expect a javascript programmer to just know jquery but I'd expect a jquery user to learn about javascript.
JQuery is a very important part of javascript development these days, so yes I would expect a JS developer to know how to use it even if its just the basics.
One of the reasons that it has suddenly gained momentum in the business app development arena is that Microsoft have given it their backing and have agreed to have it distributed with their latest web frameworks (See ASP.NET MVC).
It all depends on what they were developing.
If the web application extensively used ajax, which you could argue it should if possible) then JQuery is a excellent way of doing this. JQuery reduces development times over solely javascript.
Bottom line, if it was me doing the recommending Yes, know both
I would expect JavaScript developer to know jQuery because it's famous for a reason.
I wouldn't expect them to know jQuery, if they could use it, then it'd be better, since I prefer jQuery to all of the rest. It is possible that he/she has their own preference over jQuery, as many people do.
Jquery is pretty popular these days. It make development much more efficient and easy. And there are tons of plugins and scripts available to choose.

Learning Javascript vs. jQuery

I got the Wrox.Beginning.JavaScript.3rd.Edition and wanted to start learning it from scratch, then my boss came along and said that why bother, learn jQuery.
Can I understand jQuery and work with it although I am a newbie and have limited knowledge in ASP.net, vb.net, some C#, and basic HTML?!
jQuery is javascript. I think you're on the right path. Learn javascript well and you'll be able to make better use of jQuery.
So what's your question? JQuery is a framework built on the top of a language JavaScript. To use JQuery confidently, you should get familiar with JavaScript. JQuery contains a bunch of useful patterns and utils that mask the incompatibilities of the browsers. Using a JavaScript framework make sense as it allows you to focus on your problem instead of the problem of the JavaScript implementations of the browsers.
For further details on JavaScript frameworks, see SO question »Which Javascript framework (jQuery vs Dojo vs … )?«. For learning JavaScript, learn the good parts.
if all your manager is asking from you is to show and hide some elements, or fade in and out a couple of images, or request some data via ajax and display it then learning jquery and its api is perhaps all that you need.
but if you (or your manager) are concerned about performance, maintainability, code reuse and generally understanding what the *ell is going on 'back there' then learning the language itself is a safe bet.
I would suggest grabbing a copy of JavaScript: The Definitive Guide, which will give you a general understanding of what it is and how to use it, and much more. While you are at it, I also suggest John Resig's Pro Javascript techniques. This guy really knows his javascript inside-out (works for mozilla, author of jQuery, amongst others).
As for jQuery, you don't really need to buy a book. Just browse through the API and have a look at its source code. Perhaps you won't understand much, but there are some cool stuff going on that will make you think.
It is entirely possible to learn jQuery without learning every bit of javascript first. However, to be productive and and extend the functionality of plugins etc you will need to know javascript.
I would suggest that you do a bit of both. Continue learning Javascript but when you want to implement functionality make use of the jQuery library.
I would say the statement is akin to you reading a C#/VB.Net book and having your boss say "Don't bother, just learn ASP.Net". You really don't get much from the latter without the former.
JQuery provides a good layer of abstraction for interacting with DOM elements. You can do a lot of interesting things with it quickly and easily. But there are probably many things that JQuery won't do for you. You'll need to use regular JavaScript for that.
jQuery removes the need for many bad Javascript habits.
However, you will frequently need to know more than just jQuery to get non-trivial work done.
You'll need to learn both, but try to pick up habits based on jQuery.
jQuery is made from javascript. :)
It would be a very good idea to read the source-code of jQuery to enhance your overall understanding of javascript...
Definitely learn both at the same time :)
Good luck and have fun.
Maybe your boss is trying to save you some time learning the basics of Javascript and start you off learning jQuery right away but I think this would be a bad idea.
Understanding the basics of javascript is key to using jQuery successfully. jQuery provides shortcuts and solutions to problems (cross browser problems etc) but it is not a language unto it's self.
My advice, learn javascript, learn about handling events in different browsers, inserting in to the DOM and then start using jQuery. You will appreciate it a lot more and be a better coder for it.
If you already have an understanding of C#, you'll have a head start learning Javascript and it shouldn't be too hard to pick up. I'd stick with that Javascript book though, since you need to know Javascript to use jQuery. Once you are comfortable with Javascript, move on to learning jQuery. The jQuery docs are VERY helpful and can answer almost any question you have.
Good luck with learning it, it'll be worth it.
jQuery Docs
what are U doing? - ofcourse pure JavaScript is better =)
Libraries will alwas contain nonessential complexity, but they can save some headaches if they're not too bloated or already present on the end users' systems. Best use would be to learn javascript while using jquery, and then slowly remove the crutch of using jquery. While it's powerful, it does add significant overhead, nonessential complexity, and potential opportunities for abuse, just like flash. There are no silver bullets.

Why would I want to use jQuery? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
(I understand that someone else asked a similar question and it was closed as 'argumentative', but I'm really interested in understanding the arguments around this.)
I know JavaScript really well. I've been writing it professionally for years. I've internalized a lot of the cross-browser incompatibilities and sketchiness, know DOM manipulation like the back of my hand, have worked with some of the best web developers in the industry & picked up a lot of their mojo.
I've been checking out jQuery. I understand the point of a javascript library (how many times have I written animation, getElementsByClass, and hide/show functions?). But to be honest, it seems like a waste of time to learn an entirely new syntax that isn't less complex. It seems like I'd be bashing my head against a wall to learn an entirely new interface to the same old JavaScript.
I'm not technically an engineer, so maybe I'm missing something. Could someone spell out the tradeoffs of jQuery? Is it really faster to learn and understand jQuery syntax than to just learn JavaScript?
There are a few big benefits to using a framework over homegrown/handwritten code:
Abstractions. I'm sure you're very proud of the fact that you've slung enough JS to be able to write animations from scratch. You should be! However, abstracting common functionality away from yourself is actually very liberating. You just call the method and know the innards will be executed, and executed well. Even if you're very fast at writing the low-level stuff yourself, that's still time you've spent on that instead of solving today's problems.
Common language. Using a common framework is like speaking a common language. You can collaborate with other developers very easily, and each can pick up where others left off without friction. (Compared to stepping into an application which uses a homegrown library for the things jQuery can do.)
Experts. The people working on jQuery are JavaScript gods. I am really, really good at JavaScript, and you probably are too, but there's a big difference between normal good and jQuery good. A team of insanely good people are constantly poring over a small set of common functionality - tuning it, tweaking it, enhancing it to make it the best it can possibly be. That represents a huge number of man-hours a single person like you or me simply cannot reproduce, no matter how good we are. And if you are as good as the jQuery guys, you can only benefit by combining your talent with theirs and contributing to the jQuery codebase. It's a melting pot of insane talent.
I'm not technically an engineer, so maybe I'm missing something. Could someone spell out the tradeoffs of jQuery? Is it really faster to learn and understand jQuery syntax than to just learn JavaScript?
jQuery is more than "just another interface" to Javascript. It allows you to express yourself in ways that are more compact and succincter than the corresponding Javascript implementation. At the same time, it's clearer and much more powerful. Specifically, the benefits you get include:
Expressiveness. jQuery is essentially a DSL for DOM manipulation and querying. This specificity is a major source of its utility and effectiveness.
Cross-browser. To a very large extent, jQuery is "write once, run anywhere". Even in 2009, this is still a surprisingly rare feat for web-based platforms. It's gratifying and relieving to know that you won't have to waste time debugging obscure problems on IE6 (well, most of the time).
Highly complete documentation. As a developer, I prize APIs and frameworks that have taken the time to spell out what all the moving pieces are supposed to be doing. Nothing is more encouraging than knowing that (1) things are stable enough that writing documentation isn't an attempt to hit a moving target and (2) things are useful enough that they've attracted enough people to flesh out the documentation fully.
In sum, the difference between Javascript and jQuery is analogous to the difference between assembly and higher-order programming languages. Although they're both technically both "an interface to machine language" and can both do similar things, the latter is considered far more powerful because of how easy it is to represent things and develop rapidly.
One thing I don't see mentioned is that the library is written to work cross browser on a wide range of popular browsers and platforms: IE6+, Firefox 2+, Safari 3+
That alone is reason enough to use jQuery then to write your own JavaScript and have to worry about cross browser issues yourself.
You can't learn jQuery without learning JavaScript, and you can't be a jQuery guru without being a JavaScript guru.
That said, it really is much faster to do things with jQuery than with "bare metal" JavaScript. Moreover, the way one works with jQuery is at a far more abstract level than the way one works with "bare metal" JavaScript. In addition, the jQuery syntax is very basic and not at all hard to learn, although the way you think about jQuery is very different from the way you think about "bare metal" JavaScript but enables you do to much more, much more rapidly.
community support
other developers writting and testing code, make it possible for you to do things you simply do not have time to do. Its not about doing anything you do not know how to do, its about doing things quickly, efficiently, and of very high quality (its already been tested).
From the sounds of it, you know much of the same stuff that jQuery knows about the DOM, and I can only assume you've built-up a nice DOM toolset for yourself over the years that incorporates all of this knowledge. In short, No, you don't need to use jQuery. However, some of the rest of us do not know as much about the DOM, and jQuery levels the playing field so we can get on with getting work done for our clients.
That is not to say you should not learn jQuery (as opposed to using it). You may pickup a few things you didn't know. The 3 main features that distinguish it from other DOM libraries (including your own probably) are:
built-in support for CSS selector syntax, useful for finding elements
methods that operate on the set of wrapped elements
chaining. Every method in jQuery.prototype (with "setter" behaviour) returns this
Personally, 1) and 3) don't hold a high premium. But 2) turns out to be huge for me. I never realized until jQuery how much my code tended towards operating on a set of nodes rather than a single node (if someone would have asked me I would have guessed the opposite tendency). 2) virtually eliminated all for loops from my code (or .forEach or however else I tended to abstract it), which was actually quite liberating. Now I notice it's the rare occasion where my code must operate on some single element.
Speed of development and turnaround of code.
One thing I haven't seen mentioned in the other answers is that, eventually, someone else is going to have to maintain your code. If it's all custom, they'll have a rougher time of it than if a more standard library is used. If that's not of any concern to you, and you don't think you're likely to need any of the really slick jQuery modules, then keep on with what you're doing.
For me, there are several benefits, like speed of development, etc.
But at the end of the day, it boils down to one thing:
It removes a HUGE amount of the cross-browser BS that can eat up so much time and resources, so I don't have to deal with it
jQuery allows you to write shorter, cleaner code that's easy to understand. Many people use it, so there are many plugins that work along with it, minimizing bloat. The same may not be true of your own personal library.
If you know JavaScript really well you should also know that jQuery's syntax isn't different from JavaScript's syntax.
What you might be referring to is the chaining idiom (used everywhere in jQuery) which seems to make things look very different from other sort of code. Well there's a reason for that, it's because it bonds really well with how the DOM works.
If you truly know JavaScript, you'll be at running speed with jQuery in under a week's time. If you don't already know your way around JavaScript, adding a layer on top might do more harm than good. But that's just like anything else!
You're going to be writing better looking and easier to understand JavaScript at a faster pace and only once — not once per browser. Downside? You're going to tack on another ~50KB of JavaScript. That's what caching is for :)
Jquery is javaScript in the hand of the designer.
It is as easy as writing CSS styles on an element.
Also Jquery is the easiest to understand, write maintain, add plugins.
I was working on a gallery program for a client (which is now exhibiting inexplicable behavior in IE6 and 7 - surprise, surprise - but I found that when I switched from bare-metal Javascript to jQuery a lot of the work got much easier. To me, it makes available the CSS view of the DOM while writing Javascript - which makes traversal and manipulation much more intuitive. Also, the cross-browser compatibility and brevity is wonderful.
It doesn't really matter if jQuery is great or awful. It's the powerhouse JS library now, used on a huge number of pages, and future browsers will have to accommodate it or be seen as themselves buggy.
What I don't like about jQuery: I'm not that thrilled about how it ignores mobile phone browsers in its test suites. It gets pulled in on all kinds of pages on mobile phones, and yet it makes no effort to ensure it works well on them.
jQuery degrades gracefully and it's one of the fastest (not THE fastest anymore though):
http://mootools.net/slickspeed/
There are many other frameworks out there, and whichever you choose, you probably wouldn't go wrong, but having uses jQuery myself, I'd definitely recommend it.
:)

Categories

Resources