Minor code reorganization

Move some of the `xdm` object setup to the top of the file and remove
the unnecessary `merge`.
Exit early if no `postMessage` support