Is there a simpler (native perhaps?) way to include an external script file in the Google Chrome browser?
Currently I’m doing it like this:
document.
As a follow-up to the answer of @maciej-bukowski above ^^^, in modern browsers as of now (spring 2017) that support async/await you can load as follows. In this example we load the load html2canvas library:
async function loadScript(url) {
let response = await fetch(url);
let script = await response.text();
eval(script);
}
let scriptUrl = 'https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js'
loadScript(scriptUrl);
If you run the snippet and then open your browser's console you should see the function html2canvas() is now defined.