<button type="button" id="btn_load">load jQuery</button>
<p id="msg"></p>
function loadJS(_url, _loadedFunc){
  const add_script = document.createElement('script');
  add_script.src = _url;
  add_script.onload = _loadedFunc;
  document.body.appendChild(add_script);
}

document.getElementById('btn_load').addEventListener('click',function(){  loadJS('https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js', function(){
  alert('JS LOADED!');
  $('#msg').html('This text was written using jQuery.')
 });
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.