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.

okay, will try!