Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 488 Bytes

README.md

File metadata and controls

19 lines (15 loc) · 488 Bytes

Javascript module that exports a function to load external JS on the fly. A script is not included more than once so multiple places on the page can attempt to load the same script.

Basic usage:

import scriptLoader from 'ohjs-script-loader';

await scriptLoader(
    'https://maps.googleapis.com/maps/api/js',
    () => {
        return window.hasOwnProperty('google')
            && window.google.hasOwnProperty('maps');
    }
);

console.log('Google Maps API is ready!');