I am a self-taught web developer/programmer. I started out about two years ago by learning how to make simple dynamic websites with HTML/CSS/PHP. Then I started dabbling with animation...
I've become quite proficient with jQuery over the last year and I've even started making my own plugins. I've spent most of my effort learning how to beautify websites with fancy effects and what not.
Upon tackling my first full-blown application, I realized how under-developed my knowledge of JavaScript actually is. jQuery has allowed me to rely on its framework so heavily that I rarely use any interesting functions, techniques, or whatever that are 'native' to the JavaScript language.
I have a basic understanding of what a
closure
[2] is... but I am unsure where this technique can actually benefit me. Although as I understand it, that's what my jQuery plugins do with (function ($){//plugin code here})(jQuery)
. I've seen many posts/blogs/whatever about
memory leaks
[3] and
circular references
[4] which is concerning.
I'm frustrated because I can wrap my head around the basic concepts of what these are just by reading the articles, but I'm finding that the deeper I go the more I don't understand. The vocabulary alone is burdensome. Let alone how to actually use these techniques/functions/language features.
I am trying to figure out what I don't know
I'm looking to gather any advice, techniques, articles, books, videos, snippets, examples, potential pitfalls... really anything you have regarding application development with JavaScript.
There are several books about just JavaScript and not jQuery that should be able to help.
JavaScript the Definitive Guide [1]
JavaScript: The Good Parts [2]
Secrets of a JavaScript Ninja [3] (thanks to James Kovacs [4] for this recommendation)
and many more... [5]
Here's some specific articles on 'Advanced JavaScript'.
Memoization [6]
Memory leaks, circular references, and closures [7]
and just about [8] everything else [9]
[1] http://rads.stackoverflow.com/amzn/click/0596805527don't miss lord crockford's " crockford on javascript [1]" lecture series
[1] http://yuiblog.com/crockford/Read Douglas Crawford's JavaScript classic, JavaScript: The Good Parts [1]. It should give you some ideas aboout OOP in JavaScript and prototypal inheritance. You can find other useful resources on the author's website http://javascript.crockford.com/
I also find that O'Reily's cookbook series can give you ideas about how to use languages in ways you have not thought of. JavaScript Cookbook [2] and JQuery Cookbook [3]
Of course reading the questions here on SO can help [4].
As always the documentation is your friend. I use Mozilla's Development Center [5] for JavaScript and JQuery has excellent documentation [6].
[1] http://rads.stackoverflow.com/amzn/click/0596517742This [1] is the best article about javascript module pattern i found. You can also have a basic idea about what is closure and object scope in javascript.
[1] http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-DepthI would recommend reading Javascript: The Good Parts, as an essential tutorial to JavaScript.
I would also highly recommend reading through the jQuery source, since the project is familiar to you, it is very well documented and follows good coding conventions.
I just suggest Nicholas Zakas's Professional JavaScipt for Web Developer. It is a really great book starts from language basics and covers deep topics in JS and also advanced technics. This book is my indispensable.
Professional JavaScript for Web Developers @Amazon [1]
Then a JavaScript developer needs to read "The Real JavaScript Master" Douglas Crockford's JavaScript: The Good Parts book. It is the industries milestone.
The Master's Milestone @Amazon [2]
[1] http://rads.stackoverflow.com/amzn/click/047022780XThis is by no means a full resource, but the information here is definetely worth a read:
It's an article about optimizing your JavaScript, written by software engineers at Google who made GMail and Chrome. Really good stuff if you're looking to improve your code.
If you're really in the mood to chop up some cool web applications, you should try to grok Closure Library [2]. Some of it is rocket surgery, but you can learn a lot of good habits and best practices by working with the framework. (It's the same framework that runs GMail and Google docs)
Also, always remember to run your code through JSLint [3]. It'll make you cry!
[1] http://code.google.com/speed/articles/optimizing-javascript.htmlAfter I picked up jQuery, with a year of Ruby on Rails on my shoulders, I stumbled on:
Javascript Object Oriented Programming [1].
It really helped me getting the hang of javascript and made me appreciate a more functional style while fitting it all in my object oriented mindset.
After that book I actually went back to my ruby code and deleted some classes and functions here and there and replaced them with procs (functions you can throw around)
[1] https://www.packtpub.com/object-oriented-javascript-applications-libraries/bookYou could go through jQuery's source. You can learn some fun stuff about javascript from that ;)
I'm on the same exact boat. Personally decided to go back to basics and do all the javasript tutorials at the W3Schools [1]. If there's better resources out there for understanding how to best code js for those without CS backgrounds, i'd love to see them.
[1] http://w3schools.com/js/default.aspI learned a lot by writing my own jQuery plugin. It gave me a hands on project that posed some interesting problems and forced me to learn more about the inner workings of JavaScript.
If you take it one step further and publish your plugin at the jQuery web site, you will have people that download, use and comment on your code. Knowing that you will put effort into making sure that the code you release is good. Of course you'll always make mistakes, but that's part of the process.
Regarding memory leaks when you work with jQuery, I found that using the .data() method [1] is a good way of storing data in a safe way (avoiding circular references and thus memory leaks).
So, come up with an interesting or just fun idea for a jQuery plugin and start coding! If the plugin is a user interface plugin, consider basing it on the jQuery UI widget factory. It's a great base for developing new user interface plugins.
Best of luck!
/Thomas Kahn
[1] http://api.jquery.com/data/Eloquent Javascript [1] is a good starting point, follow that up with Javascript: The Good Parts [2]
[1] http://eloquentjavascript.net/