- Posted by Peter on February 8, 2010
I was playing around with the Silverlight 4 beta and was trying to get my webcam working by following this article. Although the code to achieve this is very simple, the webcam did not work in my *.aspx page which contains my Silverlight component. I googled and stackoverflowed around but didn’t find anyone with the same problem as I had. When the page loaded, I just saw an empty rectangle and Silverlight did not ask for permission to access my webcam like it should.
This is how the component looked in Firefox and this was the code, it’s the same as in the article:
Then I realized that all examples I saw on the web used a button before enabling the webcam. So I changed my component a little: added a ‘Turn on camera’ button and copied the code to start the camera to the click event of the button. If I now clicked the button, Silverlight asked for permission to use the webcam.
So the resulting code looked like:
And I was a happy coder, because I could now see myself in the webcam.
I documented this for everyone who might have the same problem. I don’t know if this is a known bug or not I didn’t find any documentation or ticket about it.
- Posted by Peter on January 28, 2010
A while ago Chris Missal asked the following question on Twitter:
One of the projects I am currently working on is a JavaScript intense web application. That’s why the question instantly caught my attention, JavaScript editing in Visual Studio has been bugging me for a long time. In one of my previous posts about Visual Studio somebody said in the comments that VS isn’t build with web developers in mind. Well, that’s the least you can say. But still, since my business is mainly focusing on .Net web development I’m obligated to use Visual Studio for all my ASP.Net Webforms and MVC projects. And for all the JavaScript, (LESS)CSS, ASPX, HTML editing that comes with those projects. If you don’t know it yet, Visual Studio is really bad at all those things. In those cases the editor is comparable to a colored version of Notepad.
Some of the replies to Chris’ question suggested Notepad++ others suggested RubyMine. RubyMine from JetBrains, the same company that created Resharper, is a tool I always wanted to try out and I thought this was the perfect opportunity. So I downloaded the whole thing, there is a trial available, installed it and pulled my Scripts folder into the editor. I didn’t have very high hopes, because I use JavaScriptMVC and jQuery on this project and I thought it would be very hard for the IDE to figure out all the different references and relations between the files and classes. To my surprise the IDE succeeded in parsing the different JavaScript files. So we were all set, time to try some stuff out:
I created this simple class, using the functionality JavaScriptMVC provides for creating classes:
First thing to try out that comes to mind, let’s declare a variable that is not used and see what RubyMine says about it:
Very nice, this thing is already doing more than Visual Studio does. It detects unused variables.
Time to try some more complicated like things renaming a variable which is not possible in Visual Studio. So I tried right clicking on the variable and there is a nice Refactor item in the context menu. A very Resharper-like experience, I haven’t tried out all of them but the basic things like Extract Method, Rename and Introduce Variable worked very well.
All this is really impressive, and there is more! I have multiple classes in this project and RubyMine detects them and provides Intellisense. Even though I use a framework to declare my classes, it still detects which are classes and what functions are defined on my class. Pretty nice huh? On top of that, all R# shortcuts that you are used to also work in RubyMine. Ctrl+N to find a given file, even Ctrl+12 to list and find a method of the open class:
Although I only scratched the surface of RubyMine, navigating, editing and refactoring JavaScript has been a great experience. Certainly when you’re used to using Visual Studio for that. I can already conclude that it beats Visual Studio in every aspect when it comes to writing JavaScript. It’s a shame that we have a feature-rich tool like Visual Studio and still need to open a second IDE to edit JavaScript files. I can only hope that Visual Studio 2010 brings some more options to the table. Maybe JetBrains should think about adding an ASPX editor and a C# compiler to RubyMine, call it SharpMine and sell it. That would definitely be something I would consider buying.
- Posted by Peter on December 20, 2009
I had the chance to try out NDepend, thanks to Patrick. After playing around with it I was pretty impressed and started writing a review of it. Out of curiosity I googled around a bit and found that there are already a lot of good reviews about it. I didn’t want to do just another review so instead I was thinking of creating a round up of all the blog posts out there that give more information about one or more features of the product. And which I used to get up to speed.
I don’t think the tool still needs an introduction. But for the .Net developers who have been programming on Mars in these last years. Here is a short intro: NDepend is a static code analysis tool. It collects information about your code base and gives you the opportunity to view it, query it, analyze it and so much more. Actually it is packed with features to help you in better understanding your codebase and its problems. It even has integration with Reflector and Visual Studio.
So here goes:
Getting started
Introduction video’s on the NDepend website The NDepend website has some really good video’s on how to get started. If you want to start anywhere, start here.
Hanselminutes episode on NDepend This podcast episode is ancient in Internet age (from 2007), but it does provide some interesting information.
Interview on DotNetCurry with Patrick Smacchia, the creator of NDepend Patrick talks about he basics of NDepend: what it does, when and how to use it
Introduction by Andre Loker Simplify code using NDepend Introduction by Gil Fink NDepend for Instructors This article gives the tip for instructors to use NDepend to check on code written by students. I think that’s an excellent idea!
Getting up-to-speed on NDepend and Code Metrics on InfoQ Talking .Net Code Analysis with Patrick Smacchia NDepend and complex methods Using CQL queries to pinpoint complex methods in your code base
Day-to-day working
Analyzing the code base of CruiseControl.Net Patrick analyzes the CruiseControl.Net codebase with NDepend
NDepend analysis inputs Using NDepend on large project, a success story Working on F# with NDepend by Steve Gilham Using NDepend to help guide refactoring Steve Wright wrote a great article how to use NDepend to make your code more understandable and manageable. Although written in 2008, it still is applicable today.
Static Analysis and generated code Skip generated types when performing analysis in NDepend Remove assemblies from Dependency Graph in NDepend Lessons learned from the NUnit code base NDepending Resharper CQL (Code Query Language)
Beginning CQL Getting started with CQL post by Stuart Thompson
Code Query Language Specification Active conventions with NDepend part 1 and
part 2 Jan uses CQL and NDepend to enforce BDD naming convention in his unit tests.
Fun with NDepend Integration
Video on adding NDepend to your Nant script on Dimecasts.net NDepend task for Nant NDepend and CruiseControl.Net Integrating NDepend code metrics into an NAnt / CruiseControl.Net Build Extra
Influence the future of NDepend If you’re missing a feature, this is for you. Patrick calls out the community to propose missing features for NDepend.
XDepend, NDepend for Java CppDepend, NDepend for C++ Reviews
There are a lot of reviews out there, there is not one negative review and they all have some interesting information about NDepend. Worth checking out! Here they are (in some kind of alphabetical order).
By Manuel Abadia
By Vagif Abilov
By Gojko Adzic
By Donald Belcham
By Nick Berardi
by Steve Bohlen
By Laila Bougria
By Chris Brandsma on Elegant Code
by David Brown
By Jeff Brown
By Herbert Joey Calisay
By Henry Cordes
By Ben Griswold
By Scott Hanselman
By Brian Hartsock
By Travis Illig
by Philip Japiske
By Brendan Kowitz
By David Lambert
By Anatoly Lubarsky
By Hendry Luk
By Elijah Manor
By David Mohundro
By Muhammad Mosa
By Diego Muñoz
By Keyvan Nayyeri on DotNetSlackers
By Benjamin Nietschke
by Grant Palin
By Jan Van Ryswyck
By Steven
By Craig Stuntz
By Steve Trefethen
By Ben Watson
By Davide Zordan
By Arjan Zuidhof
Closing
If you still need some reading material, I suggest you follow Patrick Smacchia’s blog. He’s the creator NDepend and frequently blogs about the subject of static code analysis. If you have an interesting link about NDepend to add you can always leave a comment and I’ll add it to the list.
- Posted by Peter on December 6, 2009
It has been quiet on this blog lately but I’ve been very busy with work. Between my busy schedule I’ve been trying to keep up on the technology front by listening to different podcasts. Although the quality of a lot of podcasts is highly dependant on the guest that is starring in that week’s episode, Scott Hanselman has been able to keep me interested all the time. Even for topics in which I’m not 100% interested in. If you’re not listening to his podcast you should subscribe right now.
I particularly enjoyed episode 187 with guest James Bach. Apparently James is a famous Software Tester, although I first thought the podcast would teach me a thing or two about software testing I didn’t know yet I was actually surprised that it was more about how to advance your career. Every software developer knows that IT is a very fast moving sector to be working in. Each day some tech company brings out a new technology that could make your current skills and thus you as a person obsolete. That’s why it is so important to continuously keep learning.
James has a rather unconventional school career, he dropped out of school at the age of 16. And he based himself on the American constitution to convince his teachers that he didn’t have to do homework at the age of 12. Everything he learned is based on passion, he only learns about things which he is truly passionate about. What I took away from the episode is that I have to try each day to keep learning and to stimulate myself to be a continuous learner. To do that I am now trying to, even more then I used to, read blogs and books, watch videos and listen to podcasts.

The best advice that was given is summarized by the following question you can ask yourself:
How can I feature myself as someone unique?
In these times of crisis and people losing their jobs all of the world. It is important to have skills that make you unique. You’ll probably never be the best programmer in the world or the best CSS guru, there is always someone better than you. But by keep learning new things you shape yourself as unique person with a very broad skill set. The more you know, the more valuable you become.
James also wrote a book about this subject which I think will be a great read. I quickly added it to my reading list. I just need Amazon to create an international version of the Kindle DX so I can start reading.
To finish off I would like to talk about upcoming posts. Patrick Smacchia was so kind to provide me with a review copy of NDepend. So I’ll be playing around with it and blog about it. I can already say I’m very impressed.
Till next time, hopefully It won’t take half a year for me to write another blog post.
- Posted by Peter on July 26, 2009
There has been a clear shift in the way I use Visual Studio lately. Visual studio has a lot of built-in panels to help you develop the next killer application. There are a lot of panels I hardly ever use. Most of my time I spend, not quite surprising, in the text editor editing code. As for the other panels I may be using about 10% of all available options. Windows like the Server Explorer, Document Outline, Object Browser, I don’t think I ever opened them while developing. And I didn’t even mention the designers yet. I am a full-time web developer but I never open the HTML designer.
So I would like to propose a Visual Studio redesign, let’s just throw out all the designers and unnecessary windows (like when editing a css file lose the CSS properties, Manage Styles, CSS Outline windows) and go back to basics. Build a really good text editor. Once everything is stripped to the bare minimum add a panel which gives you direct access to the command prompt. I got this idea from a Ruby on Rails editor called RadRails. You can generate controllers, models, etc… from a panel within the IDE.
Why a command prompt? I have noticed that developing isn’t centralized in Visual Studio any longer. Next to Visual Studio I always have a command prompt open. By using tools like JavaScriptMVC and LESS, I now use the command prompt very frequently. By running small commands from the command prompt snippets of code are generated for you. And although code generation is considered evil by some, there is a big difference between Microsoft code generation and those tools. They generate code for you but give you the opportunity to change it without any effort. The Microsoft way of code generation, the part I can remember because I try to use it as less as possible, is saying: do not touch our generated piece of art, you are not worthy. And if you dare to change it, it will smack you in the face for doing so. With code generated by Microsoft I constantly have the feeling that I’m not in control.
So my proposal is, stop building a huge beast with gazillion panels which tackles it all. Create a light weight text editor, let’s call it Textmate for Windows, and give users the possibility to add the tools they want to use in addition to that text editor by accessing them through the command prompt directly in the IDE.
I’ve googled around for a solution but the only posts that came near were posts which let you launch a command prompt from within Visual Studio. Not really what I was looking for. Let’s hope the Visual Studio Team has implemented this option in Visual Studio 2010…
- Posted by Peter on July 18, 2009
This is the third article on JavaScriptMVC, so if you’re interested in more these are my previous posts on the subject:
In these previous posts I’ve shown you the MVC capabilities of the framework, now I would like to look into its combining and compressing features. By now you should be familiar with the js.bat command file which comes with JavaScriptMVC. If this doesn’t ring a bell, please read my previous posts or go to the JavaScriptMVC website.
Justin, one of the co-authors of JavaScriptMVC, mentioned in the comments of my previous posts that reducing HTTP requests is the number one performance enhancement recommendation by the Yahoo performance team. They even have a list of best practices for speeding up your website. JavaScriptMVC can help you combining your javascript files, external files as well as files generated by the framework. It’s actually very easy to do. To reference your JavaScriptMVC project in your HTML page you use the following code:
<script language="javascript" type="text/javascript" src="../../jmvc/include.js?tab_manager,development"></script>
At this moment JavaScriptMVC is running in development mode, which means no combined files, no compressing. It loads up the files in your browser just as you created them. This can be easily checked with Firebug. Load up your page which references the javascript in Firefox and enable the Firebug Script tag. If you open up the list of script files you’ll get something like this:
All files should be in this list: controllers, external resources, … This comes in very handy when developing and debugging. But lots of different files are loaded so performance wise this is not the way to go. Fortunately we have JavaScriptMVC to help us. You can load the production version of your code by using the following HTML code:
<script language="javascript" type="text/javascript" src="../../jmvc/include.js?tab_manager,production"></script>
Notice that the ‘development’ parameter has been changed to ‘production’. That’s pretty easy huh? Now let’s reload the webpage in Firefox and see what the result is.
Quite a surprise! We went from twenty or more javascript file to only two files being loaded: index.js and production.js, both are provided by JavaScriptMVC. But how and when is the production.js file created? It is done manually using the js.bat command file once again. You can compress and combine all your files using this command:
js apps/{application_name}/compress.js
So if we take the example of the previous post, to generate the production file for our Tab Manager:
js apps/tab_manager/compress.js
This will combine and compress all your files referenced by JavaScriptMVC into the production.js file. Whether it’s a controller, a model or an external resource it doesn’t matter. Even jquery itself is combined into this file when referenced as a resource in your JavaScriptMVC application. It doesn’t matter if the original file already has been minified, this all just works.
As you can see the framework offers you a great way to enhance the performance of your web application without much effort.
- Posted by Peter on July 11, 2009
This is one of those things that you only need on very specific occasions. I needed to get the element that has the focus on a page. Went to Google and found the answer somewhere deep into a forumthread. So for future reference here goes:
Internet Explorer supports the document.activeElement property which gives exactly what I was looking for: the element that has the focus. Because you always have to be careful about javascript properties that are described on a MSDN page, they could be Internet Explorer only, I decided to write a little test to see if it works in the major browsers. I tested this in the following browsers (and corresponding platforms):
Internet Explorer 6 - Windows
Internet Explorer 7 - Windows
Internet Explorer 8 - Windows
Mozilla Firefox 3.5 – Mac
Mozilla Firefox 3.5 – Windows
Google Chrome – Windows (only works for textbox and select elements)
Safari – Mac (only works for textbox and select elements)
Safari – Windows (only works for textbox and select elements)
For the Webkit browsers (Safari, Chrome) it appears that the document.activeElement property will only be set if the element that has the focus is a textbox or a select element. Where the other browsers also report if a checkbox or a radiobutton has the focus.
This was my testing HTML file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="c/style.css" media="screen,projection" type="text/css" />
<script src="j/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="j/index.js" type="text/javascript"></script>
</head>
<body>
<input type="text" id="text-box" /><br />
<input type="checkbox" id="checkbox" />
<label for="checkbox">checkbox</label><br />
<select id="select">
<option value="1">Testing</option>
</select><br />
<p>
Current active element: <span id="current-active-element"></span>
</p>
</body>
</html>
With a little bit of javascript attached to it:
$(function()
{
setInterval("updateActiveElement();", 500);
});
function updateActiveElement()
{
$('#current-active-element').text($(document.activeElement).attr('id'));
}
This test page will write out the ID of the active element every 500 milliseconds so we can clearly see which element has the focus.
James Goodfellow has written a post about the property which is now, according to his post, part of the HTML 5 specification. For browsers that don’t support the property, James provides a workaround.
If you want to test it yourself, I uploaded the test page.
Tags from Technorati:
html,
focus
- Posted by Peter on July 6, 2009
DISCLAIMER: I recently started using JavaScriptMVC and got to like it a lot. These blogposts are a way for me to document my learning process of the framework. There is the possibility that I misinterpreted certain principles or abusing the framework at some points. So don’t be afraid to ask questions or set things straight in the comments.
In my last post I outed my love for JavaScriptMVC. I got the remark of James that a library that consolidates javascript files doesn’t make it MVC and that is absolutely correct. But JavaScriptMVC is much more then just javascript file consolidation. In this post I would like to show the MVC capabilities of the JavaScript framework and how a typical application built with JavaScriptMVC is structured.
When you download the framework and unzip it to the folder of your choice you get the following file structure:
We will touch some of the folders and files in this structure. The js.bat is a very important one because we will be generating a lot of the files via this command file. As an exercise I will build a fairly simple tabbed interface using JavaScriptMVC. I’ve put the result of this tutoria online. The initial mockup of the application looks like this:

Before we can start writing code, we have to create an application. You can do this by navigating in a command prompt to the folder where you unzipped the JavaScriptMVC bytes and executing the following command:
js jmvc\generate\app tab_manager
The batch command has generated a couple of application files. This batch file will also be used to generate models, controllers, views and much more. Before we go any further let’s digg into how JavaSciptMVC uses the MVC pattern. From their website we get the following explanation for models, views and controllers:
Model
wrap an application’s data layer, this is done in two ways:
- request data from and interacting with services.
- Wrap service data with a domain-specific representation
Controller
event delegation that helps logically organize your event handlers
View
Is used as a templating library, it builds html strings from JSON
While using the framework I took the liberty to use parts a little different. Controllers I use as defined for event delegation. But models I don’t use solely for requesting data from a service. I try to make my models as fat as possible and also do things like UI manipulation. Because I use JavaScriptMVC in combination with ASP.NET my usage of the View has been limited. I will be mainly speaking about the Models and Controllers given that my *.aspx (or *.ascx) page is my actual view.
When generating the application, JavaScriptMVC generated an index.html page for us which automatically includes the necessary javascript. We’ll be using that page to create our tab control. I changed the HTML a bit, this is the end result:
<html>
<head></head>
<script language="javascript" type="text/javascript" src="../../jmvc/include.js?tab_manager,development"></script>
<style type="text/css">
li
{
border:solid 1px #000;
float:left;
margin-right:5px;
padding:10px;
}
li.selected
{
background-color:#000;
}
li.selected a
{
color:#fff;
}
p, ul
{
margin:0;
width:300px;
}
p
{
border:solid 1px #000;
height:200px;
padding:10px;
}
ul
{
list-style-type:none;
height:41px;
padding:0;
width:300px;
}
</style>
<body>
<ul id="tab_manager">
<li class="selected"><a href="#tab-1">Tab 1</a></li>
<li><a href="#tab-2">Tab 2</a></li>
<li><a href="#tab-3">Tab 3</a></li>
</ul>
<p id="tab-1">Tab 1 selected</p>
<p id="tab-2" style="display:none;">Tab 2 selected</p>
<p id="tab-3" style="display:none;">Tab 3 selected</p>
</body>
</html>
Some basic CSS rules and HTML to represent the tabbed control. I think this code speaks for itself, let’s create the javascript that is needed to make this control work. In order to respond to events that occur we first need a controller that will do the event delegation. So we use the js.bat command batch to generate a controller, this is the command:
js jmvc/generate/controller tab_manager
In our controllers folder we now have a tab_manager_controller.js which we will use to hook into the events that occur on our html page. We can hook into different sort of events and
all the important ones are supported. So in order to respond to a click on one of the tabs we add the following method to the controller.
TabManagerController = MVC.Controller.extend('tab_manager',
/* @Static */
{},
/* @Prototype */
{
'li click': function(params)
{
new Tab().select(params.element);
params.event.preventDefault();
}
}
);
Let’s reflect over this code. This code defines a TabManagerController class which controls an element that has the id ‘tab_manager’, the id that our ul-tag has. There is one function in the controller that will respond to a click event on a li-tag. Notice how they use CSS selectors to define the event handlers. No real rocket science here for anyone who already is familiar with JavaScript and CSS selectors. Now we could write all necessary code in the controller, but in order to keep my JavaScript code maintainable I would like to use the controllers as a delegation mechanism to my models. This is somewhat different from what the guys of JavaScriptMVC are recommending to use models for. I try to get my models to reflect the different concepts in my application. So we want to generate a Tab model to show and hide the different tabs. Again we use the batch we are already familiar with to generate the model:
js jmvc/generate/model ajax Tab
This will generate a Tab.js file under the models directory. Now we can add the necessary methods to this class in order to manipulate a certain tab. The nice thing about this is that it resides in its own class which has a name that reflects the actual UI object it will manipulate. You might have noticed the ‘ajax’ parameter we have provided. This is simply because a model has to be generated with a certain data type (json_p, ajax, xml_rest, …). We will not be using one of the types in our code so this can be ignored for now. This is how the implementation of the Tab model looks like:
/**
*
*/
Tab = MVC.Model.Ajax.extend('Tab',
/* @Static */
{
},
/* @Prototype */
{
getTabContentSelector: function($tab)
{
return $tab.find('a').attr('href');
},
hideTabContent: function(selector)
{
$(selector).css('display', 'none');
},
showTabContent: function(selector)
{
$(selector).css('display', 'block');
},
select: function(tabToShow)
{
var $currentSelectedTab = $('li.selected');
this.hideTabContent(this.getTabContentSelector($currentSelectedTab));
$currentSelectedTab.removeClass('selected');
var $tabToShow = $(tabToShow);
$tabToShow.addClass('selected');
this.showTabContent(this.getTabContentSelector($tabToShow));
}
}
);
Notice that I use jQuery in the mix. jQuery and JavaScriptMVC are actually very compatible. You do have to include jQuery as a resource in order to be able to use it, more on that later. There are four functions in the Tab model, the most imporant one is the select function which takes a tab (which is actually an li-element) as argument. The content to show is currently hidden in the page, each tab has a corresponding p-tag which holds the data for that tab, but this could be replaced by an Ajax call in order to request some data for a specific tab.
The last thing I have to mention is the tab_manager.js file in the app folder. That file looks like this:
include.resources('jquery-1.3.2.min');
include.engines();
include.plugins(
'controller','controller/scaffold',
'view','view/helpers',
'dom/element',
'io/ajax',
'model/json_rest','model/xml_rest'
);
include(function(){ //runs after prior includes are loaded
include.models('Tab');
include.controllers('tab_manager');
include.views();
});
This is actually the main file of our application which determines what resources, plugins, models and controllers are loaded. As you can see the jquery file, the tab_manager controller and the Tab model are present in this file. Don’t forget to add new models and controllers to this file, otherwise they will not be loaded and executed.
Because this post is already rather lengthy I will leave it here and give you some room to expirement with the code. I know there are a lot of concepts that are left unexplained but I’m planning on writing a few more posts to go into further detail into certain concepts of the framework. As always if you have any remarks the comments are still open and free.
To finish would like to end with a brief overview of the important files and folders so you have a nice overview of where to find everything we used in this tutorial.
apps
tab_manager.js general application file to load models, controllers and resources
index.html file which holds the necessary html code, used for testing purposes
controllers
tab_manager_controller.js controller which responds on events coming from the tab manager
models
Tab.js model which represent a tab
resources
jquery-1.3.2.min.js jquery file
Source code of this article
Result of this tutorial
Tags from Technorati:
JavaScriptMVC,
JavaScript
- Posted by Peter on June 22, 2009
I'm very passionate about the code I write, and with the coming of jQuery I really began to love Javascript. But the Javascript I wrote was more of the procedural kind. I tried to split it up per page or user control but it still felt bad. For pages with a lot of interaction the JavaScript files grew very quickly over a couple hundred LOC. There is the possibility to split these up, but the problem that then arises is that the browser launches a request for each javascript file. And most (older) browsers have a suprising low amount of simultaneous request (I thought it was around 2 or 3, it was certainly below 5). So each file I added to make my application more maintainable resulted in a slower application. Not a good situation to be in.
I was constantly on the lookout for something that could easily minify and merge all my JavaScript files and still keep maintainability while developing. I had read solutions of people who had a build task that did this for them. But that seemed like a pretty vulnerable system. The build script has to create a new file on a certain location and has to change your pages so they include the correct javascript file (the newly generated one). So I lived with the pain.
Until I read about JavaScriptMVC on Ajaxian and decided to check it out. What is JavaScriptMVC? I'll quote from their site:
JavaScriptMVC is a framework that brings methods to the madness of JavaScript development. It guides you to successfully completed projects by promoting best practices, maintainability, and convention over configuration.
So it uses some conventions and the MVC pattern to give you the ability to manage your JavaScript code. But the biggest thing I like so far is the possibility to run in different modes (development, test and production) and if you run in production all your javascript including your external libraries like jQuery get minified and combined into one javascript file. Yes that's right even if you have a dozen javascript files, after minifying them you'll only have one file called production.js left. The big advantage is that the browser only has to do one request to the server to load all of the javascript. You know what that means, faster loading times!
If you write a lot of JavaScript code, check out JavascriptMVC right now. I'll be writing more details about the framework in the coming weeks as I'm still in the process of learning it.
- Posted by Peter on June 6, 2009
I started reading this book about 6 months ago. After reading it half way through I stopped and start reading a newly purchased book. The reason that I stopped reading was because I was excited and impatient to start reading the new book, it's a problem I have every time I purchase a new book. After finishing some books I realized that jQuery in Action was still lying around, and because the new project I'm working on depends heavily on jQuery, I decided to pick up the book where I left off and finish it.
If you use jQuery in your day job or you are interested in JavaScript development in general this book is really for you. I read this book after several months of jQuery development experience and still learned a lot about the framework.
The authors of the book recommend reading the appendices first before getting into the real stuff. They are a very good start for people who are not that familiar with JavaScript and get you up to speed on some essentials of the language like the JavaScript Object and how functions and closures work. These concepts are explained in a very clear way.
After the appendices you dive right into the jQuery goodness with the explanation of the pure basics. Selectors are a very important part which is handled in detail. Via events, animations and effects they show the basic utility functions that are built-in in jQuery. Although the whole book is a very interesting read chapter 7 really pops out and shows how you can write your own plugins, which can result in a lot of code reuse when used properly. The book is finished with how to do Ajax calls with jQuery and some of the best jQuery plugins.
I think it's quite clear by now that this book is a good read for all levels: beginner, intermediate and advanced. I've learned a lot about jQuery that made my job a lot easier. And I think that's the reason why we read technical books, broaden your horizon and learn how to use framework and tools more efficient. The authors certainly succeeded with this book.
To close I would like to list my 5 favorites things I learned or learned more about while reading the book:
- Selectors, although I already knew a bunch about supported selectors I learned some new ones that I didn't know of
- animate() that enables you to create your own custom animations and gives you endless possibilities
- $.grep() can be used to filter arrays
- $.post, $.get, $.ajax, ... all the different features in jQuery that support ajax calls to the server and a reference of all the different options.
- Live Query plugin, which can monitor if certain events occur on elements which match a certain selector. The good thing about this plugin is when adding new items to the page that match the selector, you don't have to bind the events for this new item. The plugin takes care of that.
Tags from Technorati:
jquery,
javascript,
book