After all the terrific feedback that I received from my post on the Untold Secrets of JavaScript I began to compile a Table of Contents that would serve as a guide for the rest of my next book (final title or publisher as yet to be determined).
I’d love some feedback as to the structure and contents of the full table of contents, as it stands:
- Introduction (Overview of the contents of the book; introduction to its style and format.)
- Test-driven book
- Test suite and examples
- Perf. test suite and examples
- The advanced features of the JavaScript Language
- How to tackle cross browser code
- Overview of best practices
JavaScript Language
Looking at the most advanced features of the JavaScript language, in depth, completely analyzing how they work and how they can best be used to implement incredible production code.
- Functions (Explain the importance of functional programming and show it’s severe capabilities and applicability.)
- call/apply
- arguments slice
- Math.sum()
- typeof fn == “function”
- fn.length
- makeClass()
- Closures (In-depth explanation of how closures work, their applicability, and usefulness throughout the language.)
- How closures work (interactive visual)
- Events & Timers
- fn.bind()
- Currying
- Self-replacing functions
- (function(){})()
- Loops
- Library wrapper
- Scope / Private Variables
- .call(this)
- Timers (In-depth explanation of how timers work internally in the JavaScript engine and how to take advantage of them.)
- How timers work (interactive visual)
- Using closures w/ timers
- Central Timer Queue
- “Threading” CPU-intesive tasks
- Object Prototypes (An overview of prototypes and how they can be used to build complex data structures.)
- Gotchyas
- Speed benefits
- Native Prototypes
- Class-like code
- Inheritance
- Namespacing
- RegExp (A deep look at the functionality provided by the JavaScript RegExp engine.)
- .replace(re, fn)
- Non-capturing RegExp
- Backreferences
- Pre-Compiled RegExp
- Unicode
- Escaped characters
- with(){} (Understanding how with works – its benefits and how it can be best used.)
- Understanding with: Pros and cons
- Packages and Namespacing
- function test(){with(this){ … }}
- Templating
- eval (How the eval function can benefit the clarity and functionality of your code in a cross-browser manner.)
- new Function
- eval.call
- <script> eval
- Packer
Cross Browser Code
An in-depth look at solving the most common JavaScript tasks in a cross-browser manner. All solutions will be constructed in a robust manner, able to handle all modern browsers.
- Strategies for Cross-Browser Code (A look at how to tackle cross-browser issues in real-world, production, code.)
- Test Test Test
- Defensive writing
- Reduce to common denominator
- Browser sniffing
- CSS Selector Engine (A top-to-bottom look at how to build a pure-JavaScript CSS selector DOM selection engine, including a look at implementing performant features using XPath.)
- Overview of CSS Selectors
- #id
- .class
- getElementsByClassName
- Descendant selectors (merging, uniqueness)
- Attribute selectors
- Child selectors
- Pseudo selectors
- XPath for HTML documents
- Translating CSS to XPath
- DOM Modification (Analyzing the cross browser issues that occur when dealing with DOM modification, injection, and removal.)
- HTML to DOM deserialization
- Injecting HTML snippets
- Inline Script execution
- cloneNode
- empty/remove event cleanup
- Text contents
- Get/Set Attributes (Digging into the nitty-gritty of handling cross browser DOM attribute code.)
- Different names (cssText, etc.)
- href/src in IE
- id in IE/Opera
- type in IE
- className
- Input values
- XML Documents
- Get/Set CSS (Implementing a completely cross browser CSS access and manipulation implementation, even working when elements are display: none.)
- Camelcase / Different names
- display: none CSS
- Height/Width
- Elements
- document
- window
- Opacity
- Events (Handling how to work around all of the most common cross browser event issues and looking at how to implement advanced features like custom events and throttling.)
- Maintaining ‘this’
- Event propagation
- Fixing Keyboard Events
- Blocking keyboard events
- Arrow keys
- Fixing Mouse Events
- Cursor Position
- Position relative to element
- Custom Events
- Delegation
- Throttling
- Animations (Look at how to build a full, cross browser, DOM animation engine.)
- Tweening
- Smooth Animations (Timers)
- Stop/Pause
Best Practices
The best techniques that you should employ when developing JavaScript applications. All solutions will look at the deep knowledge and tools needed to build production JavaScript code.
- Unit Testing (Looking at the features of existing test suites and implementing our own, from the ground up.)
- Components of a Test Suite
- Async Testing
- Performance Analysis (Looking at the best techniques for improving JavaScript performance coupled with how to analyze those changes with a speed test suite.)
- Building a Perf. Test Suite
- Firebug
- Techniques for improving performance
- Validation (Looking at the different validation techniques, how to best understand their results, and apply them to your code.)
- Understanding the Pros & Cons
- JSLint
- JavaScript Lint
- Strict
- Debugging (How to tackle the debugging of applications and libraries within a variety of browsers.)
- Firebug
- Test Generation
- Distribution (The best techniques for pulling together your JavaScript library for distribution.)
- JSMin
- Packer
- GZip
Web-Exclusive Content
A series of web-only chapters (possibly written by multiple authors) that don’t fit into the normal flow of the book, but are still relevant – and important – to modern JavaScript development.
- Text Ranges
- WYSIWYG
- Rhino
- Documentation
- JSDoc
Matt (January 9, 2008 at 3:20 am)
Where is the order form?
Luis Merino (January 9, 2008 at 3:22 am)
Hi there.
I found everything worth reading. It’d be interesting to introduce the current state of javascript, a bit of past and future of the language and why is that important nowadays in webapps, I use to like all that stuff. There’re a lot of “secrets” in the TOC as you well say… When are you planning to publish it? :D
John Resig (January 9, 2008 at 3:30 am)
@Matt: Soon… soon… ;-)
@Luis: I think I can integrate some of that into the introduction. I have some more thoughts concerning the “current state of JavaScript” that I need to have clarified in another blog post.
Right now, I don’t have a firm schedule for publishing – I’m still talking with publishers, submitting proposals, etc. Once I hit upon a combination that I like (in a time frame that’s reasonable) I’ll definitely push ahead.
I’m pushing really strongly to make most (if not all) of this book be available, freely, on the web. The result of this will depend, strongly, on the publisher and their opinions on the matter. I should have some more details concerning this, soon.
Simon Willison (January 9, 2008 at 3:46 am)
This sounds awesome. If you can’t make the whole book available for free, just publishing the chapter on closures would have a major impact on the JavaScript learning curve.
Christian Jul Jensen (January 9, 2008 at 4:10 am)
Sounds really great John, sign me up…
James Dempster (January 9, 2008 at 4:13 am)
Could try jumping onto the whole Radiohead stunt wagon. Free to download but donate as much as you like. I’d donate cause I know it’s a book that would help me. I don’t usually buy books, never really find them that helpful.
It could mean more money directly to you, although there is a risk not many people would donate. Also how would you get a hardcopy of the actual book. I don’t know of any companies that would print a ebook into physical form for you. Although that would be quite cool.
Either way I look forward to the release, time for me to save abit of cash to one side.
Arrix (January 9, 2008 at 4:16 am)
That’s awesome! Almost everything in the TOC is what I’m eager to understand in depth. It would be nice to have some JavaScript 2.0 and the future of browsers coverage in such a book. So that people can fine tune the learning direction. Which secrets will stand true in future, which will not?
Looking forward to the publication!
Peter Svensson (January 9, 2008 at 4:19 am)
order form+1
Thomas (January 9, 2008 at 4:23 am)
John,
the TOC already looks terrific. There is one issue that crossed my mind, libraries. On one side, all of your chapters have this as a cross-cutting concern, so maybe you want to include at least exemplary pointers in the chapters how the topic at hand is treated in existing libraries.
On the other side, since the main contents of the book leads nicely to library writing, you might consider devoting an entire chapter on libraries, both existing and self-written. In the case of existing libs you might argue that this information is too volatile and not generic enough for your book. But for real application programming it would be very important to treat how to hook into 3rd party libraries and make good use of them, finding criteria to choose one and so on. And you could throw in your knowledge about the existing libraries landscape.
Luis Merino (January 9, 2008 at 4:29 am)
@James Dempster: yeah, that was a great idea, I’d donate too for sure.
Pete B (January 9, 2008 at 4:36 am)
definitely buying this!
One other thing I thought of was the mouseenter/leave custom event trick, useful for dhtml
Alexander Gyoshev (January 9, 2008 at 5:59 am)
John,
The TOC’s great, can’t wait for the ‘contents’ part to come around ;-)
You could think of doing something like 37signals did with their book “Getting Real” (http://gettingreal.37signals.com/) – personally, I think their approach is great.
Whatever you decide, good luck!
Francesco (January 9, 2008 at 6:14 am)
Sounds very, very good.
When do you plan to publish it?
Mattias Hising (January 9, 2008 at 8:02 am)
Hi John,
This will in deed be interesting reading, I have been looking for this kind of black-belt-javascript book for long. The world needs to know more on this wonderful language.
Closures and Timers. Me like.
I am absolutely sure that JavaScript is going to be a huge factor on a lot of different platforms (already used in Tibco ie), this book may well be a huge success. If you can get the Best Practices chapter right, that will help thousands of developers who HATES JavaScript.
Keep up the good work John.
Ara Pehlivanian (January 9, 2008 at 8:39 am)
Whatever you end up calling it, I want a copy! :-P
Anup (January 9, 2008 at 8:42 am)
John. The outline looks great. I would second Simon Willison’s comment about making the ch. on closures free, if nothing else!
As Arrix noted, maybe some useful info on JavaScript 2 would be useful, though hard to know if it will be off topic and introduce too much politics. Any security-related things of JS now, or being introduced in JS2 could be useful.
To date, I have never purchased a book on HTML/JS/CSS (I always think they will go out of date more quickly than I will finish it!) but this one I certainly look forward too.
Justin Thorp (January 9, 2008 at 8:57 am)
yeah… you sold me. where’s the order form?
Larry Marburger (January 9, 2008 at 9:33 am)
John,
Your table of contents looks really promising. I love the idea of writing an advanced book about *JavaScript* the language and not a book about coding for a specific library.
I’m somewhat of a purist when it comes to JavaScript. I prefer to write a small supporting library that does exactly what I want the way I want it done. Everyone has a different style of coding and I love having my own library that thinks like I do. Looking at the proposed content of your book, I think this information will give people with a like mindset the tools they need to get the most out of JavaScript and not have to feel like they need to rely on an all-in-one library to do it for them.
I understand that not everyone thinks like I do — heck, I would bet that there aren’t very many people that think like I do — and that’s why there’s a need for jQuery et al.
I remember the moment the light went on for me. I was reading a JavaScript book (The Definitive Guide) with my jaw open thinking, “JavaScript can do that?!”. I must’ve repeated that hundreds of time throughout the course of that book and still do to this day. I can imagine others reading this book having the same reaction. That’s exciting.
I love JavaScript. It is by far the most fun, powerful, and elegant language I’ve had the pleasure of coding. I hope books like yours can show others the light, so to speak.
On another note. Do you already have technical editors for this book or aren’t you that far along yet?
J Christopher (January 9, 2008 at 10:34 am)
John, any reason ShrinkSafe (http://shrinksafe.dojotoolkit.org/) is not included in the distribution methods?
Kris Zyp (January 9, 2008 at 10:58 am)
This looks very comprehensive, I am also glad that you are going to be evangelizing eval and with. Simply saying eval is evil and never use with’s eliminates some really powerful use cases for them, I think. By teaching when not to use them, and when to use is them would be great.
Mauvis (January 9, 2008 at 11:10 am)
I agree with the others in and I’d certainly buy a copy when it’s out.
“It’d be interesting to introduce the current state of javascript, a bit of past and future of the language and why is that important nowadays in webapps…” -Luis Merino
I’m going to ask that you don’t expand too much on this. You, Jeremy Keith, PPK, and a ton of others have already expounded on this and we can read more up on this elsewhere. This book should just get to the nitty-gritty. Show us the goods and skip the long spiels. :)
Estevão Lucas (January 9, 2008 at 11:53 am)
John,
I await in, eager
Have very things that I would like to learn how run.
Regards
K9 (January 9, 2008 at 11:54 am)
Looks great, particularly the treatment of the language first, and then practical browser issues. I agree with Kris about eval and with, a balanced discussion of these is really needed.
How to write about libraries is tricky, since on the one hand they change the experience of writing javascript so much, but on the other the abstraction they provide can serve as a barrier to really getting to know the nuts and bolts of the language…
Ryan (January 9, 2008 at 12:47 pm)
Wow, the TOC looks awesome. I will definitely buy the book. We’ve been needing something like this for a long time.
Dethe Elza (January 9, 2008 at 1:01 pm)
I’m looking forward to this, and it’s been a looooong time since I’ve looked forward to a book on Javascript.
Chris Anderson (January 9, 2008 at 1:26 pm)
Wow, a lot of comments already!
What about a section on the same-origin policy and writing widget / mashups? This is more of the end (web-specific) part but certainly the kind of thing where having an understanding of the fundamentals (rather than just cargo-culting implementations) is crucial.
Wade Harrell (January 9, 2008 at 1:27 pm)
there is always the free PDF download with an option to use a print-on-demand service; although bookshelves and distro are handy too.
My design company did the layout for an RPG that used lulu.com and it has been working out pretty good for them. Since you already have a rather large captive audience this might be a good option for you.
Other POD services I know of but have not used: lightningsource.com (http://www.fonerbooks.com/pod.htm) & booksurge.com
Patrick Wolf (January 9, 2008 at 1:54 pm)
Sounds very interesting!
Looking forward to read it :-)
Patrick
Matt K (January 9, 2008 at 2:35 pm)
I hope your chapter on closures references this page:
http://www.jibbering.com/faq/faq_notes/closures.html
The technical detail in that page is excellent. Also, be sure to address the potential memory leak scenarios when using closures, particularly in IE. It would be great to have an in-depth examination of what causes the leaks, patterns that create leaks, patterns that avoid leaks, ways to clean up the leaks, and when you can ignore the problems entirely.
Also if
>typeof fn == “function”
refers to sniffing out if something really is a function, I hope you get into details about why this is fundamentally impossible, point out the more robust attempts at getting it correct and what the pros/cons are, and finally why the “need” to figure out if something is a function may actually point to bad design decisions.
The chapter on RegExp would be great with some advice on optimization, too. Pages like this are great:
http://blog.stevenlevithan.com/archives/faster-trim-javascript
For the chapter on cross-browser code, I hope it doesn’t evangelize browser sniffing as a good approach. It would be great to really dig into the difficulties of writing cross-browser code without browser sniffing, how it can be done, and why some believe that browser sniffing is still a better approach.
I think the TOC looks great, and if you really dig deep into the issues and provide detailed and technically deep information on the topics, this will be one of the best JS books ever written. Enough with reference books. People need the gory details, and few writers are able to really write about them. Good luck!
Steven Levithan (January 9, 2008 at 3:34 pm)
@Matt K: Hey, thanks for the mention :)
@John Resig: Section 6.4 “Pre-Compiled RegExp” is IMHO not something that should really be highlighted, since the RegExp.prototype.compile method is mostly worthless in JavaScript and is deprecated by ECMA-262v3 (see http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Deprecated_Features ). Also, only the latest versions of WebKit support it (see http://bugs.webkit.org/show_bug.cgi?id=11001 ).
NICCAI (January 9, 2008 at 3:47 pm)
Count me in. Looking forward to it.
Jörn Zaefferer (January 9, 2008 at 6:51 pm)
I wonder if something like “Designing [libraries] for extension” fits into the TOC somewhere.
I’d be happy to help out anywhere! Its so much easier to order a book and give it to your eager coworkers then trying to teach them at work or just pointing to scattered blog posts.
I wouldn’t use the term “Best Practice”. I’ve seen it being misused way to often, eg. as a knock-out argument. And I don’t want to look back in three years and think, well, it may have been best practices then, but we are much further now. You can’t cover everything anyway.
In spite of that: Great TOC! I’m really looking forward to a first draft…
Vijay Santhanam (January 10, 2008 at 4:17 am)
Sounds like a massive, dense, thorough book. I’d definitely buy it
Steve Goguen (January 10, 2008 at 12:34 pm)
Wow… That is an awesome TOC, and sounds like a lot of work on your part. :) Nevertheless, I’d love to have that on my bookshelf.
frrua (January 11, 2008 at 7:33 am)
Wow, this should be titled “The Book of JavaScript”!
Matt H (January 11, 2008 at 8:35 am)
This looks to be the JavaScript book I’ve always wanted.
Dave McFarland (January 11, 2008 at 4:45 pm)
This looks fantastic. I’d be VERY happy with just parts 1 and 3. Since I’m rather library-dependent, most of the cross-browser issues I’d normally encounter are solved for me.
dre (January 12, 2008 at 5:26 am)
Is there anyway you can release chapter 10 early. Say like write it this weekend and release it later next week as a sample chapter?
Vikas (January 14, 2008 at 12:55 am)
@John,
One more topic suggestion,
Can you add one sample chapter with a Object Oriented JavaScript Programming ?
One side of page may contain C++(Java,PHP) OOP code & other side contain equivalent JavaScript code. That will be better to understand JavaScript OOPs clearly.
+——————————————————-+
PHP (C++,Java,Pseudo code) | equivalent JavaScript code
class abc{ |var abc = function(){
function abc(){ | init_abc_construct();
// constructor | function init_abc_construct(){
} | }
private function xyz(){ | function xyz(){
// code | // code for xyz
} | }
public function pqr(){ | return function(){
// code | // code for pqr
} | }
}; | }
…. |
+——————————————————-+
Steve Finkelstein (January 14, 2008 at 4:26 pm)
Definitely looking forward to anymore books which you’re authoring. One subject I find sorely lacking in many JavaScript books is front-end caching using js. caching of objects and such is something I’d love to see made available in a text book.
Jim Plush (January 16, 2008 at 7:22 pm)
I’m in, publish that sucker already so I can buy it :)
Steve (January 19, 2008 at 9:56 am)
John,
I would like to see a chapter on the creating APIs for mashups,such as the googledata API and cover the today way of doing cross site updates and authentication (multiple iframes – google calendar) along with future Firefox 3 ways.
All this combined with the considerations with embeding javascript includes from other domains and the way you should code with them such as subspace.
I think the chapter should also include best practices with JSON and webservices.
thanks
Reggie Drake (January 21, 2008 at 3:56 pm)
Very promising list. Have you considered writing something about doing (relatively) portable vector graphics? (see this).
Eran Galperin (January 24, 2008 at 3:24 pm)
The single most important item to me would be code design – A chapter dedicated to explaining the proper coding practices for javascript, which despite years of use is still a very open topic for me. My own style was influenced mainly by reviewing the source code of the profilic JS libraries such as jQuery and Dojo, but there are some design choices that I couldn’t understand and I have yet to see a book cover this important subject.
Javascript, being a client side and prototype based language, has such different approaches to code design than the traditional server-side languages I am more proficient in, those also having much better coding practices references. If you put this chapter in your book, I guarantee I’ll buy a copy for each of my team members ;)
Jon Ronnenberg (January 25, 2008 at 11:32 am)
In the Distribution section I wonder why the YUI Compressor isn’t mention. It’s my favorite, very easy to use compressor.
@Vikas
Here is a typical C# class as JS with an optional configuration object in the constructor:
ClassTemplate = function(config){
// private variables (fields in C#)
var _pVar;
if(config && config.PVar){
_pVar = config.PVar;
}
// private properties
// getter/setter
var _pVarField = function(value){
if(value){
_pVar = value;
}
return _pVar;
};
return {
// Public methods
SetPVar : function(value){
this.PVar = _pVarField(value);
},
// Public default properties
__type : “ClassTemplate”,
PVar : “default value”
}
};// add () if you want a singleton class (the configuration object should be removed)
Cheers!
Dipen Chaudhary (February 14, 2008 at 6:06 am)
Hmm I would like to read more text than code on following topics:
1> CSS selector engines (The technique, idea and prolly pointers to how jQuery CSS selector engine works )
2> HTML to DOM deserialization ( how that works) because if I understand that I can myself figure out how to do nifty queries on DOM
3> Events->Delegation, Events->throttling ( equal amount of code as well)
Few Other stuff I will be looking forward to:
1> Async testing with selenium or something better and how to write tests or pointers to that
2> More details on applicability of closures and more details on how closures work at a noob level (I understand its not a beginner’s book, but might even help a seasoned JS devel)
And a additional chapter on hints to read jQuery code :)
Thanks a lot for thinking about to make it freely available, but more importantly pick a publisher which publishes it in India like Apress or Wrox or Addison Wisley ..
Nate Klaiber (February 14, 2008 at 10:26 am)
I knew you were writing a book, but was a little late to finding this page. The table of contents look incredible and I will definitely be getting a copy when it comes out.
Oliver Steele (February 14, 2008 at 5:54 pm)
This looks awesome.
On the subject of timers and closures, you might be interested in http://osteele.com/sources/javascript/sequentially/. It goes a bit overboard (IMO), but I’ve ended up using most of the ideas there in more mainstream work.
John Campbell (February 24, 2008 at 1:10 pm)
Looks awesome.
Would you consider a section on templating / string interpolation. I find a common coding practice is to receive json, convert it to html, then bind events. Should we be using XML/XSLT? Should we use a templating language, or just use string concatenation.
This document is an interesting discussion of the issues:
http://google-caja.googlecode.com/svn/changes/mikesamuel/string-interpolation-29-Jan-2008/trunk/src/js/com/google/caja/interp/index.html
David Betz (February 25, 2008 at 11:06 am)
Awesome! I’m thrilled to see someone write a doctoral-level guide on the topic. I have a feeling this book will raise the bar of JavaScript/AJAX education very high– something that’s long over due. This should really help further separate the professional JavaScript programming from the web coding hackers.
Hodicska Gergely (May 17, 2008 at 10:37 pm)
This looks really awesome, I can’t wait for the printed version. It would be great some kind of early access version or something similar. Good work!
Best Regards,
Felh?