7 ms·
John Resig: Secrets of the JavaScript Ninja Update
- danso 14y agoI've written a few short-ebook-like technical posts and it still surprises me the number of people who ask for when the PDF format is coming... I get that not everyone can have access to a web browser at every occasion they have for reading...but the web provides a much better canvas for illustrating technical concepts, especially with the ability to create interactive bits with JS. Save the couch reading for leisure/non-technical reading, and read technical pieces when you're on the computer (and have ready access to Google/StackOverflow). On a selfish note, writing HTML seems to be much easier than producing a properly formatted PDF page. So I enjoy technical writing, but not enough to go through the hoops of for-paper (or paper like e-books) publishing.
- why-el 14y agoI was actually thinking about this earlier. Why is pdf so hard to deal with? And why is around in the first place? I can imagine a future where html5/js combo is enough to convert a set of html pages to a nice offline-supported readable format. With that said, I usually just go to the print page of some links and read. You will be surprised how many sites inadvertently give the best reading experience through their printer page (NYT for example)
- saraid216 14y ago> And why is around in the first place? PDFs predate both CSS and the legion of webdevs we have available now. It's effectively vestigial. However, PDFs do allow for digital signing, which is not a feature webpages can have AFAIK.
- danso 14y agoI don't know if it's hard as I've never tried. But as I've tried a lot of ways to print websites as PDFs, through various third-party services, I'm assuming it's not at all straightforward... I think the "hard" part is properly paginating things? And I guess generating table of contents, inner-book-links, things that my blogging platform (Octopress) handles in a way that I've been used to as a Rails templater.
- peterarmstrong 14y agoWe can import blogs and generate ebooks (PDF, EPUB and MOBI) at Leanpub. The idea is that you should self-publish as you write, and that starting with a blog is a great way to start. We generate a table of contents, support crosslinks, etc. It may be what you want...
- tonyedgecombe 14y agoThere are a number of things that don't quite transfer like headers and footers, keeping blocks together and of course paper doesn't have scroll bars.
- brlewis 14y agoPDF exists because the format allows a UA to render any given page in a document without having to render the whole document. With PostScript you had to run the entire program to accurately know what would be on a particular page.
- petercooper 14y agoAnd why is around in the first place? I can imagine a future where html5/js combo is enough to convert a set of html pages to a nice offline-supported readable format. Same deal with MP3 vs other formats. PDF is a sort of gold standard in being able to precisely lay out text and know it'll render mostly right on most devices (even if the format/layout is wrong for those devices). HTML5 and EPUB are getting there but vary so much between different platforms that till now (and EPUB 3 is changing this) the quality of books in those formats has been hideous production wise. Compare the typical EPUB book against the typical PDF book in terms of whitespace, layout, fonts, and how the author and publisher intended it to look.
- danmaz74 14y agoDid you give a try to wkhtmltopdf? http://code.google.com/p/wkhtmltopdf/ http://code.google.com/p/wkhtmltopdf/
- fsckin 14y agoWhat a fantastic tool. Thanks!
- skyhook_mockups 14y agoIf you're interested in HTML->PDF without the hoop jumping have a look at princeXML. It's incredibly good.
- javajosh 14y agoI really admire Resig, and this post contains a few gems: 1. Knew about PPK[0], didn't know about JZ[1] 2. Feature detection came about from writing this book! Which generalizes too: writing is a great way to innovate (something pg has said, too). 3. A nice little jab at GRRM, who thoroughly deserves it. 4. An exciting glimpse into the future of computer science pedagogy by way of JavaScript in the browser. (And I can't help but wonder if this is an oblique response to the recent Alan Kay Dr. Dobbs interview, where Kay asserts, "The Web, in comparison, is a joke. The Web was done by amateurs."[2]) 5. Points out that even the best of us can get stuck in a procrastination loop. 6. Resig is going to finish a JavaScript book [3] [0] http://www.quirksmode.org/ http://www.quirksmode.org/ [1] http://perfectionkills.com/ http://perfectionkills.com/ [2] http://www.drdobbs.com/architecture-and-design/interview-with-alan-kay/240003442?pgno=1 http://www.drdobbs.com/architecture-and-design/interview-wit... [3] http://jsninja.com/ http://jsninja.com/
- oinksoft 14y agoRegarding #2, regulars on comp.lang.javascript have been saying this since at least 2008, notably in critiques of jQuery. Resig even posted to some of these threads defending jQuery's misbehavior (though I don't recall if he defended browser sniffing). I find it very surprising that it took the act of writing a book to realize this fundamental design flaw. And for those who will want to say "oh, that's just because David Mark is so grating," quite a few mild-mannered regulars reached the same conclusion, so it's not as though there was one firebrand suggesting this.
- gilini 14y agoExactly. Eventually everyone turned to feature testing and it became common sense in clj. comp.lang.javascript's FAQ on browser-sniffing: http://jibbering.com/faq/notes/detect-browser/ http://jibbering.com/faq/notes/detect-browser/
- oinksoft 14y agoI think you and I are saying the same thing, but to be clear, this was "common sense" on CLJ long before mainstream libraries adopted the practice.
- r00fus 14y agoJohn is a really great guy and has done (at least for me) more to advance the knowledge of javascript than any other person I know. Very fitting that he's now at Khan Academy. I've personally bought the jsninja ebook for friends and myself because I thought it was a great read and wanted to contribute to this kind of effort.
- ville 14y agoI haven't read the book, but this praise of with statements struck me as odd: "The portions of this book that cover features that are relatively un-changing, such as code evaluation, with statements, and timers are continually being used in interesting ways." There also seems to be even a whole chapter in the book dedicated to with statements. What are those interesting and great applications that justify this feature, being considered harmful[0] and even removed from the language in strict mode of ES5? [0] http://www.yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/ http://www.yuiblog.com/blog/2006/04/11/with-statement-consid...
- jeresig 14y agoEvery where you see the "with statements are harmful"/"eval is harmful" drum being hit, you see Douglas Crockford. He's a great guy, and I really respect his opinion, but I continue to feel that these are legitimately useful aspects of the JavaScript language -- especially if we want to consider JavaScript as the "assembly language" upon which other languages are built. For with statements in particular, templating and scoped evaluation (I provide an example from the Firebug console in the book) are probably the two areas in which I've seen it most successfully used. For code evaluation I only have to direct you to the creation of Coffeescript (an entirely evaluated language) whose innovations have directly influenced new versions of the ECMAScript language. They have their place and when used sparingly, but effectively, the can be formidable parts of a web developer's arsenal.
- ville 14y agoI agree that code evaluation is a valuable feature in the language. But to be accurate, I wouldn't call CoffeeScript an entirely evaluated language, since it's mainly meant to be used by pre-compiling it to JS. (From CoffeeScript website: "While it's not recommended for serious use, CoffeeScripts may be included directly within the browser") Anyway the ability to eval code on the browser is awesome for trying it out or for building an IDE.
- jashkenas 14y agoI agree with what you're saying, but I'd also be remiss if I didn't quibble with this bit: > For code evaluation I only have to direct you to the creation > of Coffeescript (an entirely evaluated language) whose > innovations have directly influenced new versions of the > ECMAScript language. The standard way to use CoffeeScript is to compile it to JavaScript first, and then deploy and run with that. There's zero "eval()" involved. Or rather, doing direct "eval()" of CoffeeScript is possible, and on occasion fun, but is discouraged for all the usual reasons.
- kevinpet 14y agoI was looking forward to learning how to do a javascript ninja update, which I assumed might mean some kind of "reload the latest version of the JS while the user is on the page".
- anthonyb 14y agoCongratulations! Writing a book is insanely hard.
- twfarland 14y agoReally respect that he chose to prioritise his personal life. Reminds me of the lesson I learnt from Herbert and Harry as a child. http://www.penguin.com.au/products/9780140567830/herbert-harry http://www.penguin.com.au/products/9780140567830/herbert-har...
- eswangren 14y agoIs a "JavaScript ninja" conceptually similar to a "my little pony samurai"?
- ck2 14y agoIt's been so long I completely forgot I bought the book! The best way to get a project done is to 1. need the money 2. not get paid until you finish If either of those elements are missing, expect delays ;-)
- cdr 14y agoWhile it's disappointing that it's taken this long for the book to get finished, the publisher Manning has provided downloadable drafts throughout the whole process - a great feature. Thanks to that I've had access to the book (such as it's been) for pretty much the entire time, and that's what pushed me to buy it when I did. Can't wait till my paper copy ships - guess I better make sure my address is accurate still :)
- cheap 14y agoToo bad I cancelled my order years ago...
- cheap 14y agoWhat? The book is going to be great.