Load JS equivalents after dom is ready

Includes portions of the fixes from @jsjant.

Fixes #4