Use API functions based on availability

Hi,
I'm using es6-module-loader in a custom javascript environment and made these changes to avoid errors.
I have a window object, but do not have a document.getElementsByTagName, I have an XMLHttpRequest but no require.

To make sure that the functionality is actually there - there might be a lot of different environments, and I would check the availability of features on a per feature base.
if XMLHttpRequest exists -> use it.
if require exists -> assume node.js environment -> use http/fs lib.
if some future thing exists -> use that.