TL;DR I’m working on a series of books that explore Modular JavaScript in five instalments. I’m launching a crowdfunding campaign to help finance the endeavor. Drafts of the first book, Practical Modern JavaScript, are publicly available under HTML format and under an AsciiDoc source code repository on GitHub.
A while after I published JavaScript Application Design with Manning Publishing, I felt like writing again. JavaScript Application Design was a wonderful thing. When the pile of books arrived at my doorstep, I could finally point at a a physical thing and say “I made that” – it was such a thrill.
Half of the book was dedicated to explaining how to lay out a build process. Most examples in those chapters relied on Grunt. Even though the explanations weren’t tightly coupled to Grunt, as you could easily translate the concepts to other build tools like Make
or npm run
, Grunt was pervasive enough that the book had an appendix on how Grunt works, another on Gulp and npm run
, and a few explanations of Grunt sprinkled all over the book. The other half of the book talked about modular design, REST API design, testing, asynchronous JavaScript, and how to uphold quality in applications in general. You can look over the table of contents for a better idea of how that book was structured.
This time, I’m diving deeper.
Let’s improve our collective understanding of writing robust, well-tested, modular JavaScript code.
A New Book Series
I’ve been working on a new book – alongside O’Reilly Media – for a while now. I originally proposed writing a single book, where I’d cover ES6 language features, modularity, universality, testing, and deployment: everything you need to know to build robust JavaScript applications. As I thought about it, however, I realized it could face the same issues I had faced with JavaScript Application design. Instead of having to explain Grunt throughout, I would have to explain ES6 throughout this one, incrementally teaching different bits of the feature set as I went. I decided to turn the book into something more modular, just as I would when faced with the same problem in code.
As a result, the idea for a Modular JavaScript book series was born.
Participate in the crowdfunding campaign on Indiegogo
Share a message on Twitter or within your social circles
Amplify the announcement on social media via Thunderclap
Purchase the Early Release from O’Reilly
Contribute to the source code repository on GitHub
Read the online HTML version of the book on Pony Foo
The Modular JavaScript Book Series
Modern application design is hard.
Modular JavaScript is an open effort to improve our collective understanding of writing robust, well-tested and modular applications. It consists of five books, each of which explores a key aspect of JavaScript development — comprehensively. The books are produced in the open: anyone can track their progress, report issues and contribute fixes or content. A free-to-read version is available online! Digital and print books can be purchased via O’Reilly Media.
This may sound surprising if you’ve never written a book, but the Table of Contents is something you draft before you even start writing the first page, and it typically undergoes several radical changes as the book is being developed. It could be that the content needs better flow, some topics are deemed irrelevant or out of a particular scope, or different topics that need to be introduced.
I’ve decided to make Modular JavaScript an open effort, which is something I’ll circle back to after describing each book in the series. First off, check out the description for each book, and their currently proposed table of contents.
I invite you to look them over and chime in with your opinions. The first book, Practical Modern JavaScript, is unlikely to change a lot. The rest of them are quite likely to change dramatically as they’re developed.
Book — Practical Modern JavaScript
The first book, already in development, is dedicated to ES6. When it comes to books on a language, these tend to be more of a reference style but not so much practical. Practical Modern JavaScript aims to provide practical instances in which you could leverage the different language features, at the same time as it teaches you how each feature works.
Code examples are meant to be readily consumable and applicable to real-world JavaScript applications. This is something I strived toward in the JavaScript Application Design book, although the code samples were sometimes a bit more contrived than they had to be.
A friendly tone paired with wording that’s light on jargon are aimed towards making the reading experience as pleasant as possible.
This book will go over each feature in ES6 in detail, including how to use Babel and friends, as well as practical advice on what works and what doesn’t.
Table of Contents
I. Practical Modern JavaScript
1 Introduction to ECMAScript 6
1.1 What is ES6
1.2 First Look at ES6
2 Build Tooling Around ES6
2.3 Introduction to Babel, webpack, browserify, eslint
2.4 Compilation with Babel
3 ES6 Essentials
3.1 Object Literals
3.2 Arrow Functions
3.3 Assignment Destructuring
3.4 Rest Parameters and Spread Operator
3.5 Template Literals
3.6 Let and Const Statements
4 Classes, Symbols, and Objects
4.1 Classes
4.2 Symbols
4.3 Improvements to Object
5 Iteration and Flow Control
5.1 Promises
5.2 Iterators
5.3 Generators
6 Collections
6.1 Sets
6.2 WeakSets
6.3 Maps
6.4 WeakMaps
7 Proxies
8 Built-in Improvements
8.1 Number
8.2 Math
8.3 Strings and Unicode
8.4 Array Methods
9 JavaScript Modules
9.1 CommonJS
9.2 Modules in ES6
9.3 Exports and Imports
9.4 Module Loading
9.5 Interoperability
10 Practical Considerations
Book — Mastering Modular JavaScript
The second book in the series gets more interesting. Once we’ve established that the reader knows ES6, then we can take it for granted. That’s one of the amazing aspects of writing a book series, you can get away with things that wouldn’t make a ton of sense in standalone books.
This book is much more theory-intensive than the first, as it involves design patterns, guidelines for “thinking in modules”, principles, what consistitutes a great module, etc. That said, the book will probably involve developing and publishing a number of modules exclusively for the purposes of learning, so you can expect a decent amount of code here as well.
The modular nature of the series allows me to dig deep in this book and include tips on publishing to npm
, versioning, writing great documentation, and everything else that makes a perfect package.
Table of Contents
II. Mastering Modular JavaScript
1 Module Thinking
1.1 Introduction to Module Thinking
1.2 Brief History of Modularity
1.3 Benefits of Modular Design
1.4 What Constitutes a Module?
1.5 Why Modular JavaScript?
1.6 Future of JavaScript
2 Modularity Principles
2.1 Motivations
2.2 Single Responsibility Principle
2.3 Small and Simple
2.4 Portability
2.5 Composability
3 Shaping a Module
3.1 API First
3.2 Internal Design
3.3 Loose Coupling
3.4 Semantic Versioning
3.5 Documentation
3.6 Testing
4 Modular Patterns and Practices
4.1 Revealing Module
4.2 Object Factory
4.3 Composition Over Inheritance
4.4 Events
4.5 Conventions
5 Developing Modules
5.1 Leveraging npm
5.2 Debugging Dependencies
5.3 Introducing Webpack
5.4 Source Mapping
5.5 Automated Publishing
This table of contents hasn’t been fleshed out yet. We’re open to your suggestions!
Book — Universal JavaScript, Modules Everywhere
This book covers how we can create entire modular applications. We’ll be looking at how to reuse code across a codebase when it comes to shared logic between the front-end and the back-end.
Module interaction design will play a big part here, where we’ll try and come up with a plan to develop modules that can be plumbed together with minimal friction.
The book sets out to answer the question: “How do we scale out a module approach to fully flesh out an application without ending up with 500+ LOC modules?”
Table of Contents
III. Universal JavaScript, Modules Everywhere
1 Universal JavaScript
1.1 Reasoning
1.2 Back to Browserify
1.3 The “browser” Field
1.4 Considerations
1.5 Authoritative Examples
1.6 A Case Study
2 Interconnecting Modules
2.1 Simplicity vs. Complexity
2.2 Module Interaction Design
2.3 Scaling Out
2.4 Documenting and Testing
This table of contents hasn’t been fleshed out yet. We’re open to your suggestions!
Book — Testing JavaScript Modules
Built on the foundation of testable code laid out in previous books in the series. Plenty of real life examples!
There is so much ground to cover in testing, that it deserves a book of its own in the series. We’ll start by covering the basics, such as linting, and then move onto unit testing. The beauty of the modular nature of the series strikes again, where we can explore unit testing after we covered how modules should be designed in order to maximize testability in previous books.
Automated browser testing, asynchronous tests, integration tests, and every relevant kind of testing you can think of will probably be included in this book.
Continuous testing will be covered as well, and it will in fact be an excellent segue into the next and last book of the series.
Table of Contents
IV. Testing JavaScript Modules
1 Module Testing
1.1 Linting
1.2 Overlooking Implementations
1.3 Testing Your First ES6 Module
1.4 Assertions
1.5 Spies and Stubs
1.6 Mocking Modules
2 Integration and Continuous Testing
2.1 Integration Testing
2.2 Visual Testing
2.3 Testing Locally
2.4 Continuous Integration
2.5 Headless Browsers
2.6 Zuul and SauceLabs
This table of contents hasn’t been fleshed out yet. We’re open to your suggestions!
Book — Deploying Modern JavaScript Applications
Details on how to set up hassle-free deployment processes that don’t get in the way of productive development, yet are optimized for performance.
Optimizing an application for deployment is not exactly something you want to leave for last. After all, that’s the state in which all your users will be consuming your application. The series will progressively build towards something that’s easily optimized and then deployed.
This book covers different ways you can deploy your JavaScript applications, such as via containers or PaaS solutions. You’ll learn how to better optimize for bundle size, HTTP/2, and the trade-offs each optimization implies.
Table of Contents
V. Deploying Modern JavaScript Applications
1 Deploying Modular Applications
1.1 Compilation
1.2 Optimization
1.3 Universal Execution
1.4 HTTP/2 and the Road Ahead
This table of contents hasn’t been fleshed out yet. We’re open to your suggestions!
An Open Effort for Modular JavaScript
As I mentioned earlier, Modular JavaScript will be an open effort. What does this entail? Well, that involves a four-part answer. Let’s start with the free stuff!
Practical Modern JavaScript is Free to Read!
The book is publicly available in HTML format and free forever. Each book chapter is styled similarly to how Pony Foo blog posts — such as the one you’re reading — are styled, which makes for a fairly enjoyable read as far as HTML books go.
Every book in the series will be distributed in this way.
It took me a bit of time but I’ve managed to get the git
repository to trigger builds on the O’Reilly build server. The build server then pings back to ponyfoo.com, letting the site know a build is ready. Lastly, Pony Foo finally downloads the updated HTML files for the web version. Luckily I developed the code in such a way that I will be able to share HTML versions of other books in the series effortlessly.
Taking a page from Buffer’s radical transparency program, where they advertise salaries, equity grants, revenue, and other figures of interest, I will do my best to make Modular JavaScript’s numbers available on a regular basis. I’ll disclose the amount of units sold, my losses and earnings, and how much money I end up generating through this adventure.
The free-to-read version of Practical Modern JavaScript is subject to the same license as the rest of the content I publish on Pony Foo: Creative Commons Attribution-NonCommercial-ShareAlike.
Read the HTML version of the book on Pony Foo!
Source Code Repository!
I want this book series to be as widely available as possible, and the best course of action for that purpose was to release the vast majority of its contents to the open-source community.
The book chapters, code samples, and related graphics are all open-source and free to read online. The repository is the same one I work on while writing the book. You can help me in real-time, or just take a peek at my writing process and progress.
O’Reilly provides their authors with git
repositories under a system dubbed “Atlas” — the same system that handles the HTML and PDF build jobs. They also offer a way of using a GitHub repository while keeping their remote up to date via git hooks.
The GitHub repository is automatically synchronized with the website using webhooks and the O’Reilly Atlas API.
Those are the implementation details, but it means I can offer an open-source repository for the books — the same repository I will be working on myself. This means I can take issues, pull requests, and everything directly on GitHub. You can fork the book, fix some typos or add a new paragraph, and submit a PR.
When I merge a PR, the website will be updated after an automated build courtesy of the O’Reilly Atlas service!
Contribute to the source code repository on GitHub!
A Crowdfunding Campaign!
Offering all of this content free of charge is amazing because I can ensure that anybody who’s interested in JavaScript can learn more about it. The satisfaction alone doesn’t pay any bills, though.
At the same time, I have to manage to write the series somewhere in between my day job at Elastic (it’s the absolute best company — we’re hiring! ) and my night job life bliss being a husband.
That’s why I’m asking for your help with a crowdfunding campaign. The main concern in the campaign is to keep me motivated to find the time to see the series to its end.
The first book is already well underway, and I’d love to be able to justify the dedication that each book in the series deserves.
There’s quite a few perks in the campaign – as is the norm with crowdfunding these days. I’m sure you’ll find something to your liking. Go check out the campaign and let’s make this happen!
Participate in the crowdfunding campaign on Indiegogo!
O’Reilly Media Early Release!
I’ve partnered with O’Reilly Media to publish the book. This is a paid offering that includes a PDF ebook and eventually a print book. The published book is a great way to show your support for my work, by paying a bit for it — and telling your friends how awesome my writing is.
We’ll start with an Early Release, where you will get the first few chapters in ebook format. As new chapters come out and old ones get improvements, you’ll receive those updates at no extra cost to you. You’ll also get an opportunity to steer the direction of my writing efforts by reporting errors and delivering book reviews.
This is a great way to stay in touch with me through the writing process and letting me have it when drafts are not up to your expectations, so that we can improve the book iteratively before it goes to print.
Purchase the Early Release from O’Reilly!
Screencasts? Probably!
There’s a lot of ways to present content, but screencasts are an ideal companion for a deep-diving book series. The idea would be to interleave some content discussed in the book with an even more practical focus – perhaps showcasing concepts using code samples. Screencasts would be produced separately after each book goes to production (an intensive copyediting and proofing process publishers undergo before a book goes to print).
I’d love to shoot screencasts to complement the books. If the crowdfunding campaign goes well, we could definitely make this a reality!
Thanks!
Thanks for reading this needlessly long announcement about Practical Modern JavaScript and the Modular JavaScript Book Series, and please consider sharing this piece so that more of our peers can check out the web version of Practical Modern JavaScript and maybe even help me out with the crowdfunding campaign.
Where To?
Participate in the crowdfunding campaign on Indiegogo
Share a message on Twitter or within your social circles
Amplify the announcement on social media via Thunderclap
Purchase the Early Release from O’Reilly
Contribute to the source code repository on GitHub
Read the online HTML version of the book on Pony Foo
Talk soon.
Comments