Javascript frameworks come in a variety of flavors, they’ll typically encapsulate common practices that web developers frequently use in their sites. With the three dominant mainstream browsers (FF3, IE7, Safari and potentially even more) to worry about, each with a slightly different technique to program for, it can be a good practice to use a tested framework which works across the board and remove the overhead associated with testing common methods.
The framework which I’ve come to grow quite fond of lately is called jQuery. JQuery is best described as a type of web designers toy box that focuses on separating content from functionality. So what do I mean by this?
Here is an example setup for a jQuery project.
$(document).ready(function(){ $("#Button1").click(function(event){ alert("Say Something"); }); });
Whats nice about jQuery is that the footprint is relatively small at 54k or less, and if you prefer there is a file hosted from the Google API website which you can link to directly inside of your page. In fact you’ll find that many tasks require a minimal amount of code to achieve some impressive results.
// Resize lightbox on button click $(document).ready(function(){ $("#Button1").click(function(){ $("#lightbox").animate({ width: "1000px", height: "400px", fontSize: "3em" }); }); });
Those familiar with object oriented programming will be glad to know that jQuery also supports chainability as in this example.
$("a").addClass("test").show().html("foo");
The jQuery framework is becoming increasingly popular among many high profile sites such as Netflix, NBC and Dell to name a few. Even the Microsoft development community is taking notice as their next update of Visual Studio will be providing jQuery code completion within the software itself.
For more information on jQuery you can visit their website: http://jquery.com/