JavaScript Tutorials
Convert Image to Data URI with JavaScript
Whenever I go on a "performance run" on a website, the first place I look is imagery. Why? Because you can save an image out of Photoshop, push it into ImageOptim or even TinyPNG, and save 70% on its file size. What do most developers not consider? Taking tiny image...
Detect if a Document Has Loaded with JavaScript
If you follow me on Twitter, you've probably noticed me whining about ChromeDriver. For some reason it seems as though tests run before the document has properly loaded, leading to transient test failures and loads of frustration. I thought the best way to avoid these problems was...
Get and Set Nested Objects with JavaScript
Back when JavaScript frameworks like MooTools and jQuery ruled the land we all wrote tutorials which were framed more toward the given framework instead of vanilla JavaScript. Sad but true. These days I avoid framework-oriented posts since Node.js has taken over the world and JavaScript toolkits come and...
Get and Set Environment Variables in Node.js
One of the best ways to use sensitive information in open source repositories without hard-coding the information within publicly available repositories is setting environment variables. Set the environment variables on the server, retrieve them by key within your application. When using Node.js, you can retrieve environment variables by key from the
process.env
object: There...Intercept HTTP Requests with Node.js nock
Unit testing external APIs is difficult no matter what language you do it in. Hell, working with any external API is scary, if only because you have zero control of networking issues, API changes, and a host of other issues. But if you do create a service...
Introducing Frontend Masters (with Giveaway)
Hey DWB readers, I'm super happy to sponsor this blog. I've been a long-time reader and fan, since back when David wrote about JavaScript and MooTools back in 2007. ;-) We are in one of the fastest changing, evolving, most lively communities on earth: JavaScript and front-end web...
Get Node.js Command Line Arguments with yargs
Using command line arguments within Node.js apps is par for the course, especially when you're like me and you use JavaScript to code tasks (instead of bash scripts). Node.js provides
process.argv
but that doesn't provide akey: value
object like you'd expect: Bleh. If you want to work with a...Detect Error Type with JavaScript
JavaScript error reporting and catching is important and will only get more important as our web applications become more feature rich and powerful. I have never used
try/catch
blocks in depth -- I usually just catch exceptions for stuff that's usually known to cause problems. Remember this one from the IE6...GSAP + SVG for Power Users 2: Complex Responsive Animation
This is the second article in a series about the GreenSock Animation API and SVG. This series isn't intended for beginners, but rather a deep dive into some of the more exciting and lesser-known features that one can work with after they've gotten past the initial...
Serve a Directory with Node.js
As I mentioned in Serve a Directory with Python, sometimes you need a directory to be "served" instead of loading the
file://
location within your browser. In the past I would mess around with MAMPStack and swapping outhttpdocs
directories, but there are better tools these...