how to use webpack to load CDN or external vendor javascript lib in js file, not in html file

externals is not intended to let you do this. It means "don't compile this resource into the final bundle because I will include it myself"

What you need is a script loader implementation such as script.js. I also wrote a simple app to compare different script loader implementations: link.


var $script = require("scriptjs");
$script("//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js", function() {
  $('body').html('It works!')
});

You can create a script tag in your JS as

$("body").append($("<script src="https://forio.com/tools/js-libs/1.5.0/epicenter.min.js"></script>"))