• Stars
    star
    1,265
  • Rank 37,029 (Top 0.8 %)
  • Language
  • Created almost 11 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Things to keep in mind when making stuff for the web

Principles for making things for the web

This a list-in-progress of things I try to keep in mind when working on web projects. Some are matters of logic, others are matters of personal taste.

I manage to abide by some of these things some of the time.

Design/UI

  • The best way to make something durable and flexible is not to get too fancy in the first place. You only have to fix the web to the extent that you break it first.

  • Make sure states of your app that you want to be shareable have unique URLs. Use hashes if necessary. Assume that someone will copy the URL directly from the address bar, not from your "Share this!" widget.

  • You need a very good reason to have more than two fonts per page.

  • Don't use tiny font sizes, and be generous with line spacing for body text.

  • Don't make tiny click targets. Assume that someone will be mashing that "X" icon with a fingertip, not a cursor.

  • Redundancy is a useful design technique. Labels+icons, color+width, etc.

  • Embrace vertical scrolling, don't break it. Scroll-based animation is annoying. Stop turning the web into a popup book.

  • Don't rely heavily on hovers to make something interesting. Even if most of them have a mouse, requiring your users to go on a scavenger hunt is obnoxious.

  • If an input is going to be numeric, use the "number" input type so mobile devices can show the appropriate keyboard.

  • Use loading indicators for XHR requests, even if they're likely to be very fast. You never know how slow or broken it might be for a user. They should know if something is missing.

  • In mobile browsers, the scrollbar is often subtle or invisible. Check where your page gets cut off at those sizes and make sure it's apparent that there's more below the fold.

  • Don't break browser zoom (things like full-window maps are an exception).

  • Try not to rely heavily on audio (this includes video with voiceover). Lots of users will be in public, and even if they have headphones, requiring them to get them out and/or put them on is a big barrier.

  • Text should be text, not text in an image.

  • Make it clear that clickable things are clickable. They should have cursor: pointer, have hover states, and if they're text, they should be distinct from other text.

  • Avoid lightbox modals if possible.

  • Don't make your location-based app require a user's location. Be prepared for them to say no. More generally, if you have a very personalized app, think about what interesting things you can show someone who doesn't want to get personal.

  • Don't give someone 20 equally interesting things to do right off the bat. Give them a more focused presentation upfront before turning them loose.

  • Small multiples reflow easily.

  • Web design is not a contest to see who can have the fewest empty pixels. Whitespace is a valuable asset for focusing a user's attention. Let things breathe.

  • Limit the maximum width of text blocks to something like 900px. Anything wider becomes hard to scan.

  • Don't use Flash.

Graphics/Charts

  • Assume that people won't read the instructions.

  • Put legends as close as possible to the chart content they describe.

  • Label your axes and show your units.

  • Get live data into your visualization early. If you can't, use historical data or something else a little bit representative. Visualizing random test data will lead you astray.

  • When showing the change in a value over time, you need a good reason not to use an area chart or line chart.

  • When comparing a value for multiple categories, you need a good reason not to use a bar or column chart.

  • When comparing two variables across a set of data, you need a good reason not to use a scatterplot.

  • When showing a distribution, you need a good reason not to use a histogram/distribution curve.

  • Don't make 3D charts.

  • Don't muck around with the y-axis. Be mindful of scale.

  • Don't expect people to tell subtle differences in scale for bubble size or opacity.

  • Don't use more than three or four colors in a categorical scheme. If you have more categories than that, you probably need to use something besides color to differentiate.

  • Be mindful of color blindness when picking combinations. Use something like Colorbrewer to pick your scales.

  • Don't make slideshows/lists without a "view all" option. Better yet, make it "view all" from the start with vertical scrolling instead of requiring a dozen clicks.

  • Transitions are fun the first time and then usually annoying. Try not to use them unless you're actually trying to show persistent objects in transition.

  • Use Leaflet for maps.

  • Don't make population maps.

  • For world maps, consider using a Robinson projection. For US maps, consider using an Albers projection. Whatever the map, be aware of the distortions of your chosen projection.

HTML/JavaScript

  • Specify a charset, presumably utf-8.

  • Specify a doctype, presumably <!DOCTYPE html> (I don't know of a good reason to use any other type).

  • Include descriptive social media <meta> tags.

  • Put site scripts at the end of the <body> tag.

  • If something is going to be rendered the same way every time with JavaScript, it should become static.

  • Concatenate and minify scripts to minimize page size and number of requests.

  • Use descriptive subfolders for resources (css/, js/, images/).

  • Include version numbers in the filenames of JS libraries.

  • Cache jQuery and D3 selectors that are going to be reused:

$("div#sidebar").html("Don't do");
$("div#sidebar").html("this");

var $sidebar = $("div#sidebar");

$sidebar.html("Do this");
$sidebar.html("instead");
  • CamelCase or lowercase? Tabs or spaces? Hyphens or underscores? Picking a system and being consistent is more important than which you choose.

  • Don't poll for updates constantly. How up-to-the-second does the data actually need to be?

  • Don't leave console debugging messages in your production code.

Working with data

  • Clean and transform your raw data stepwise. Make it a repeatable process. Use Makefiles or shell scripts if you can.

  • Give data files descriptive names. geocoded-20131206.tsv, not data.tsv.

  • Link to your data sources in the final presentation. Explain your methodology, and especially explain the limits and shortcomings of your analysis.

  • Don't use really complex regular expressions if you can help it. Use multiple steps instead, you'll be less likely to screw up.

  • Round coordinates (quantize) and simplify geodata files to save space as appropriate. You don't need data to the inch to make a world map.

  • Store data as JSON or TSV.

  • Work with simple text files when possible. Avoid the overhead of a database unless your data really demands it.

  • Make sure you know the way(s) that a dataset represents unavailable values. It could be a blank space, it could be a dash, it could be an asterisk. It could be multiple things. Some places will use 999 or 99.999 to mean a number that's not available.

  • Cache pages while you scrape them so that you don't have to start over if you were scraping the wrong thing.

  • Beware the four C's of working with text data: character encoding, capitalization, curly quotes, and cwhitespace.

"Côte d'Ivoire" //damn it
"Cote d’Ivoire" //crap
"cote d'ivoire" //whoops
"Côte d'Ivoire " //what the?
"Ivory Coast" //COME ON

Site setup

  • Make things static whenever possible. If they can't be static files, cache routes with something like Varnish.

  • Cool URLs don't change.

  • Make URLs short, descriptive, and lowercase.

  • Use http://domain.com/, not www.domain.com - but configure www. to redirect to the former.

  • Flush POST data so it can't be resubmitted with a refresh.

  • Try very hard not to rely directly on external APIs. Use an in-between layer so that if the API goes down, your site is just stale instead of broken.

  • Assume your page will be one of user's dozen open tabs. Use short, descriptive page titles and a favicon.

  • Minify images as much as possible, and use the appropriate format. You don't need rich, lossless, giant files for tiny icons or thumbnails.

Server config

  • Don't store credentials in script files. Use environment variables.

  • Have a recovery plan, and test it.

  • Keep detailed logs, and rotate the logfiles.

  • Keep track of your server's dependencies and jobs such that you can quickly rebuild it from scratch. Have a clean AMI or equivalent.

  • If you use AWS, have at least one non-AWS fallback.

  • Use a staging server.

  • Don't rely on browser sniffing. Detect support for relevant features instead. And if you are doing too much of that, you probably got too fancy (see bullet #1).

  • If you're using a framework, make sure verbose error messages are off in production.

General process

  • Be open about uncertainty around a project's eventual form. Build with escape routes and next-best options in mind in case you hit a dead end or the data doesn't cooperate.

  • Form a team around a project at the beginning. Everyone who's going to be building something should be involved in the formative discussions. Have them physically sit together as a team if possible.

  • Build in sufficient testing time. Guerrilla test early with people who aren't involved in the project, and don't give your testers a bunch of prefatory instructions before turning them loose (your real users won't get any).

  • Don't spend too much time designing static mockups of unstatic things. Go from paper to code as quickly as possible. Graphics software is for graphics.

  • Deciding how much to care about different types of users requires knowing your users in the first place. Understand who they are, what they want, what browsers they use, what devices they use, etc. Make that the starting point when deciding what level of resources to devote to addressing different scenarios.

  • Set time aside to write good documentation. Be specific about dependencies and installation. Use real-world scenarios and variable names in your examples, no foo and bar gibberish.

Some further reading

More Repositories

1

flubber

Tools for smoother shape animations.
JavaScript
6,378
star
2

clmystery

A command-line murder mystery
5,317
star
3

learninglunches

Materials for a series of learning lunches on news development topics.
237
star
4

gifs

Testing various ways of generating gifs and videos off data-driven JS animations.
HTML
179
star
5

csvgeocode

Node module for bulk geocoding addresses in a CSV.
JavaScript
163
star
6

wherewolf

A server-less boundary service. Find what geographic feature (e.g. an election district) a given point lies in.
HTML
160
star
7

mapstarter

A tool for generating starter SVG maps from a geographic data source
JavaScript
129
star
8

ca-license-plates

Vanity license plate applications from the California DMV.
122
star
9

pancakejs

A mini-library for easily flattening SVG and Canvas elements into images on the fly.
JavaScript
86
star
10

d3-stateplane

D3-friendly State Plane projections
86
star
11

openvis

Links and bibliography for OpenVisConf 2017
84
star
12

fourscore

An open-source version of the WNYC sentiment tracker.
JavaScript
46
star
13

nflplays

Cleaned-up NFL play-by-play data from 2002-2012
42
star
14

stakeout

For watching a set of URLs and notifying someone when something has changed.
JavaScript
31
star
15

xyz-affair

Generate list of x/y/z Spherical Mercator tiles based on a bounding box and a zoom level.
JavaScript
31
star
16

endorsements

Data on newspaper presidential endorsements
28
star
17

markdowneyjr

A hacky Markdown-to-JSON parser for easier copy editing.
JavaScript
25
star
18

loopify

Seamless looping with the WebAudioAPI.
JavaScript
22
star
19

maps-nicar14

Notes for map session with Tom MacWright (@tmcw) at NICAR14.
21
star
20

d3-unconf

HTML
17
star
21

presidential-nouns

Nouns of assemblage for US presidents.
13
star
22

flipbookjs

For automatically flip-booking progress while developing something for the web.
JavaScript
13
star
23

snd3

D3.js resources for SND/NYC 2018
HTML
13
star
24

mahalanobis

Calculate Mahalanobis distances for multivariate data.
JavaScript
13
star
25

ire2014

A list of resources for getting started with interactive news projects.
12
star
26

notsimple

Chrome extension that puts quotes around any instance of the words 'simple,' 'simply,' 'easy,' and 'easily' in GitHub and RTD docs.
JavaScript
11
star
27

gobblefunk

Rename your JS variables with silly words derived from Dr. Seuss, Roald Dahl, and Lewis Carroll.
JavaScript
9
star
28

hashnav

Simple JS hash-based navigation library
JavaScript
9
star
29

oh-snap

Snap points to nearest point in a different set.
JavaScript
7
star
30

hhbaworkshop

Mapping History - A Leaflet.js workshop for the Hacks/Hackers Buenos Aires Media Party
CSS
6
star
31

headless-gif

Saving web worker'd gif via PhantomJS.
JavaScript
6
star
32

dotmapper

Auto-generate a dotmap from a GeoJSON file
JavaScript
5
star
33

node-geosupport

Node.js wrapper for fast geocoding with NYC's Geosupport system
JavaScript
5
star
34

streets

A bunch of convoluted processing for turning OSM data into Leaflet-mappable street objects with names.
Python
5
star
35

fresh-start

A full bootstrap script for a new installation of Ubuntu Desktop
Shell
5
star
36

presidential-election-results

1976-2020 presidential election popular vote totals by state and party
4
star
37

chopped-and-viewed

Node module for chopping fixed-width text files.
JavaScript
4
star
38

congressional-acronyms

Raw data on congressional acronyms, 1972-2013
3
star
39

insecurity

Analyze HTML, CSS, JS, etc. files for insecure URLs.
JavaScript
3
star
40

nicar15-scrapeoff

Gathering notes/suggestions for a Scrape-off at NICAR 15.
2
star
41

knickout

For simulating the rest of the Knicks season.
JavaScript
2
star
42

point-on-line

Test whether a point is on a line or LineString
JavaScript
2
star
43

postal-abbreviations

A no-fuss US postal abbreviations module.
JavaScript
2
star
44

BriefMemorableSlug

Generate random adjective-adjective-animal slugs
JavaScript
1
star
45

state-population-by-age

State population by age, 1960-2040
1
star
46

dst

Collecting data to visualize effects of DST
Python
1
star
47

lazy-vector-tiles

A lazy vector tile system. Not robust or high-performance, but rather straightforward.
JavaScript
1
star
48

bracket

CSS
1
star
49

rosetta

TK
1
star
50

euler

Solving Project Euler problems in JS, Python, and maybe Ruby
JavaScript
1
star
51

gulp-insecurity

Gulp plugin for detecting insecure URLs that could cause mixed content errors.
JavaScript
1
star
52

statelympics

Python
1
star
53

webpack-babel-bug-repro

JavaScript
1
star
54

fuel-prices

Misc. fuel price data
JavaScript
1
star
55

recs

Travel recommendations in Markdown
CSS
1
star
56

ticker-tape

A list of ticker tape parades in New York City
1
star
57

jsv

1
star
58

emojify

Replace PHP variable names with emojis.
PHP
1
star
59

supreme-court-transcripts

Attempting to parse supreme court oral argument transcripts.
JavaScript
1
star
60

split-multipart-features

A script for selectively splitting up multipart features in QGIS.
Python
1
star
61

nyc-css

NYC in CSS (Chrome only)
HTML
1
star