Skip to content

Instantly share code, notes, and snippets.

@tevashov
Last active April 1, 2023 02:44
Show Gist options
  • Select an option

  • Save tevashov/5172451 to your computer and use it in GitHub Desktop.

Select an option

Save tevashov/5172451 to your computer and use it in GitHub Desktop.
jQuery latest hotlink #jQuery
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js" ></script>
@dscotese

dscotese commented Apr 1, 2023

Copy link
Copy Markdown

// Adapted from https://codingbeautydev.com/blog/javascript-create-script-element/

const script = document.createElement('script');

// use local file
// script.src = 'script.js';

script.src =
'http://code.jquery.com/jquery-latest.min.js';

script.async = true;

// make code in script to be treated as JavaScript module
// script.type = 'module';

script.onload = () => {
console.log('Script loaded successfuly');
const box = document.getElementById('box');
box.textContent = 'The script has loaded.';
};

script.onerror = () => {
console.log('Error occurred while loading script');
};

document.body.appendChild(script);

//Compressed:
const script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-latest.min.js';
script.async = true;
document.body.appendChild(script);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment