How can I add jQuery to my webpage using Javascript?


My AngularJS SPA web page performs WebAPI calls to a server. When a user goes to a report page then I need to load jQuery so that it can be used. Very few users need the report page so I do not want to load jQuery at the start.

Can someone tell me a simple way to do the loading without needing to add in anything too complicated such as require.js or a complicated loader script. All I need is a very simple way to load in jQuery that will return a promise after the jQuery is loaded.

You could so something like this:

var s = document.createElement('script');
s.src = '/path/to/jQuery';

But there may be issues loading jQuery after Angular.