Move `#nav` specific Javascript into `if` block