Issue #125  (, Multimedia Tools, Testing Tools, RWD)

(Skip to the tools section below)

Here's a simple fact about global variables and ids in JavaScript: Every time you add an id attribute to an element in an HTML page, that id becomes a global variable (that is, a property of the Window object) accessible in your scripts on that page. For example, let's say you have the following HTML:
<body id="myBody" class="home">
  <div id="one">This is div one</div>
  <div id="two"><p>This is div two</p></div>
  <div id="three"></div>
  <div id="four" data-name="fourDiv"></div>
  <div id="innerHeight"></div>

You can access any of those HTML elements by simply using the values of the id attributes:
console.log(myBody.className); // "home"
console.log(one.textContent); // "This is div one"
console.log(two.innerHTML); // "<p>This is div two</p>"
console.log(; // "three"
console.log(; // "fourDiv"
console.log(innerHeight); // already global

Here it is on JS Bin

Notice that the script doesn't access the elements using getElementById(), querySelector(), or anything else. I'm simply referring to the id attributes directly. All of these could also be written as "" if you wanted to be more explicit.

But, as you'll notice with the last log in that line, this technique can cause problems. If a global variable already exists with the id value chosen, it won't work, but will instead reference the original global variable. In this case, the final example references "innerHeight" which is already a valid property of the Window object and so it just spits out the inner height of the window. Other examples include history, location, navigator, innerWidth, and much more.

So I would chalk up this little tip to "good to know" but probably not something you'll want to use, unless you're being really careful with your naming of id attributes (e.g. you use a very specific prefix to namespace all the values).

Now on to this week's tools!
Buy My JavaScript/DOM E-Book:
70 JavaScript and DOM Tips for $5 (EPUB, MOBI, PDF)

Multimedia Tools

Library to convert audio from a microphone to MP3 with JavaScript.

"HTML5-based Text-To-Speech library designed to add voice features to web sites and apps across all smartphone, tablet and desktop devices. It supports 51 languages through 168 voices, no dependencies and weighs just 14kb."

"Encode your content with the same technology as Netflix and YouTube in a way that it plays everywhere with low startup delay and no buffering."

Railroad-diagram Generator
A small JavaScript library for generating railroad diagrams (like what uses) using SVG.

SVG Icon Sprite Polyfill
A polyfill for Internet Explorer 9+ and the SVG 'use' element.

"Converts a string of SVG into an HTMLImageElement using Blob and URL.createObjectURL. Falls back to encodeURIComponent for unsupported browsers, such as Safari 8.0."

"Loads your compiled SVG sprite into the page immediately after the opening 'body' tag. The SVG sprite is wrapped in a visually hidden 'div'."

"JavaScript library for synergistic SVG icons." Nice examples on the home page.

"Make images look as if they are made out of 1x1 LEGO blocks."

A motion graphics library for the web.

"Tiny library for playing video on canvas elements."

"A 3D data visualization library built using three.js."

"An open-source, web-based viewer for high-resolution zoomable images, implemented in pure JavaScript, for desktop and mobile."

"JavaScript WebM encoder. Create WebM videos in your browser. No server-side, pure JavaScript."

70 JavaScript and DOM Tips for $5 (EPUB, MOBI, PDF)

Testing and Debugging Tools

"Compare website versions with highlighted changes before you deploy."

"Web Debugging Proxy based on Chrome DevTools Network panel. This tool will help you analyze web traffic outside the browser using familiar Chrome DevTools interface."

A bookmarklet "meant to be loaded on an existing page to highlight potentially broken, malformed or legacy (X)HTML."

SSL Server Test
"This free online service performs a deep analysis of the configuration of any SSL web server on the public Internet."

Analyze and optimize your website's web performance, SEO, security, quality, and more.

Mixed Content Scan
Scan your HTTPS-enabled website for mixed content.

Network, web, and application monitoring service.

"A functional API to unblock your JavaScript."

Live DOM Viewer
Just input some HTML and you'll get a live tree-based view of the code.

JavaScript Standard Style
"One Style to Rule Them All. No decisions to make. No .eslintrc, .jshintrc, or .jscsrc files to manage. It just works."

"A service that monitors the uptime, downtime, and performance of websites. Get 24/7 monitoring."

"Counts blank lines, comment lines, and physical lines of source code in many programming languages."

384 Pages of CSS for $7 (PDF E-Book)

RWD and Mobile Tools

Fluid for Sketch
"A Sketch plugin that provides a means to create more constraint-based, responsive designs. It is based on Auto Layout constraints."

"A mobile framework that lets you develop native iOS and Android apps from a single code base written entirely in JavaScript."

"A lightweight JavaScript library to provide Desktop-like zooming by pinch."

Responsive Grid System
A mobile-first 12, 16, and 24-column grid system for fast, intuitive development.

"A jQuery plugin that populates a table with the necessary data attributes in order to display as a list on smaller viewports."

"A 60fps infinite scrollable list for mobile devices."

"A virtual joystick for touch capable interfaces."
"Quickly build a backend for your mobile app. is an open source backend library."

"A dependency-free JavaScript library that allows you to easily use the imgix API to make images on your site or app responsive to device size and pixel density."
384 Pages of CSS for $7 (PDF E-Book)

A Tweet for Thought

Sadly, Nicholas Zakas has announced that he will not be the author of the 4th version Professional JavaScript for Web Developers (which has long been one of my go-to JavaScript resources).

Suggestions / Corrections

Made something? Send links via Twitter @WebToolsWeekly (details here). No tutorials or articles, please. If you have any suggestions for improvement or corrections, feel free to reply to this email.

Before I Go...

If you're in the market for a stand-up desk, you might want to consider Refold, a foldable, portable, cardboard standing desk.

Thanks to all for subscribing and reading!

Keep tooling,
Copyright © 2013 Web Tools Weekly, All rights reserved.

Email Marketing Powered by MailChimp