boot.js: only set the onerror handler if window is defined