In the last 2 or 3 years, we have all experienced the comeback of javascript. A language cursed in many ways, for its lack of consistency across browsers, slow runtime performance and poor tooling (debugging). The revival of Javascript is hard to miss though, given the jungle of frameworks and effects libraries that are becoming available. Even browser manufacturers are jumping on this trend by delivering javascript engines that dramatically speed up javascript execution. Javascript "2.0" seems to be the fuel for the next generation of web applications.
For long I have more or less ignored this whole trend. Most developers have enough new things to learn already, and javascript is often not the top priority. The fact that there are a lot of different frameworks (MooTools, Dojo, Prototype, jQuery, etc) does not make it any easier either.
Below are my 7 reasons why you should learn a javascript framework, and that the best one to learn about is jQuery.
1. jQuery seperates behavior from markup
In HTML markup it is still quite common to see things like this:
<form id="myform" onsubmit=return validate();" >
Even though the validate() function can be placed in an external file, in effect we are still mixing markup with logic and events here. jQuery allows you to completely seperate the two. With jQuery, the markup would look like this:
<form id="myform">
Next, the seperate JS file will contain the following event subscription code:
$("myform").submit(function() {
...your code here
)}
This allows for very clean markup with a lot of flexibility. jQuery takes javascript out of your markup, much like CSS took the style out of markup years ago.
2. Write less, do more
Write less, do more - it is the jQuery slogan, and it is an accurate one. Using jQuery's advanced selectors, you can do amazing things in just a few lines of code. You do not need to worry about browser differences (much), there is full Ajax-support and many other abstractions that make you more productive. jQuery takes javascript to a higher level. Here's a very simple example:
No comments:
Post a Comment