Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm new to JavaScript.

I've read JavaScript: The Good Parts and half of Professional JavaScript for Web Developers.

Now I want to follow this advice - find the best sites and look at their code.

As suggested by Crockford in Coders at Work: Reflections on the Craft of Programming I want to find the best sites programmed with only JavaScript not jQuery because I want to look at their code and learn from them.

share|improve this question
4  
Might be difficult: many sites minify or otherwise obfuscate their javascript. –  Rein Henrichs May 23 '11 at 9:29
7  
Quality sites use standard libraries, and jQuery happens to be most popular of them. –  vartec May 23 '11 at 9:49
1  
Using a library is useful, there's no point reinventing wheel and you end up with less code to maintain. jQuery is very popular and there are tutorials that cover the javascript that you need to know. –  StuperUser May 23 '11 at 11:07
1  
@Rein, who says he can't learn to write obfuscated code? –  The Muffin Man May 23 '11 at 12:44
1  
Considering the javascript usage trends, you might find it hard to find anything but (minified) jQuery on top sites. –  Denis May 23 '11 at 18:25
show 2 more comments

2 Answers

up vote 6 down vote accepted

Read Literate Programs

Explore code bases that use a literate programming approach (as introduced by D. Knuth), it will help greatly.

For instance:

Read Good Example Projects

Some other pages are very well documented and can be of good help to see either good practices, bad practices, and practices that are good in constrained environments but may make your code hard to read and maintain. By the way, you mention jQuery as something you don't want to use... but reading jQuery's source might also be a good idea, as well as the source of other frameworks.

GitHub, Google Code Project Hosting, Google CodeSearch and other online code hosting and browsing tools will be your friends here, and there are plenty of good projects that use a load of JavaScript.

Have a go at the following ones to see what I mean (in no particular order here):

Read Good JavaScript Programming Blogs or Essays

You may want to look for a few blogs to follow for yourself.

I don't really want to point out anyone in particular. Tastes vary, both in terms of writing style, coding style and programming paradigms. That being said, learning from people using techniques you dislike is also very enlightening.

Here are still a few for pointers:

Experiment with Different Frameworks

And this, extensively: read the code, follow the tutorials, do benchmarks.

Here are some for a start (in alphabetical order):

Sure, they will hide some of the complexity for you. So be sure to understand what's happening under the hood.

Have a look at what JS can do for you in other environments - not only on the client side - as well, for instance with node.js.

Teach yourself about the Interpreters

They run your stuff, so you better know what they can and cannot do, and how it impacts your websites rendering and performance.

Speaking of Benchmarks...

If you need to test this (and take the habit of doing so), meet your new friends:

Have a browse on the above to see great examples people published.

ECMAScript Standard

The ECMAScript standard exists for a reason. Read it, even if it is (or appears) unreadable. ECMA-262, 5th edition, is your bible for the stuff under the hood reference.

Still some complements to the standard might help...

Have a look at Google DocType and Mozilla's JavaScript Reference

Lurk on StackOverflow

Follow the tags for javascript/ecmascript questions, or for a specific framework, and read great and bad answers alike. Annotate them, comment on them, and don't hesitate to try to answer. Worst case scenario, you write a perfect answer, get tons of points and have made someone else's life easier. Best case scenario, you get shot down in flames, learn a bunch of new things, and get on to the next question to dig deeper.

Don't forget to have a look at the highest voted JavaScript questions.

share|improve this answer
    
wow thank you man ,, Great effort –  tarek11011 May 23 '11 at 18:44
    
@tarek11011: you're welcome, it's always a pleasure, especially when the effort is rewarded (by "thanks", not by points :)) –  haylem May 23 '11 at 18:50
    
Really nice answer –  dukeofgaming May 23 '11 at 19:16
    
@dukeofgaming: thanks. –  haylem May 23 '11 at 19:29
add comment

Have you considered looking at JQuery code itself? It's open source which makes it possible for you to see how the most popular Javascript framework does its magic. Maybe you could even become a contributor. Most websites will make use of JQuery, prototype, mootools etc... This is probably because javascript in it's purest form isn't a very good language when compared to other more serious languages like C#, Java and Python.

You will have to look to open source, and there again you will probably be seeing a lot of JQuery. You can probably try:

  • PHPBB - An open source forum application
  • Identica - An open source microblogging application
  • TinyMCE - An open source text editor component for Javascript.

If your going to work with Javascript on a practical basis however it may just make sense to learn the libraries.

share|improve this answer
    
jQuery itself is not a solid example of "high quality" JavaScript code. It's a popular library, but it has grown organically. –  Raynos May 23 '11 at 23:03
    
That's sad to hear. Maybe they will fix it in 2.0. Do you work on JQuery? –  Tjaart May 24 '11 at 7:39
    
No, but I've read most of it. The main problem is that it's full of browser hacks and you can't write "good code" if you need to fix/hack bugs in multiple browsers. It's more an issue of all cross browser compliance libraries get messy. –  Raynos May 24 '11 at 7:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.