I have several Cdns that I would like to load only when I call a particular function, right now I have it in the head but this makes the web slow down and it may be the case that those Cdns are not needed either. I have done it with document.write but it doesn't work.
<script>window.jQuery || document.write('<script src="assets/js/vendor/jquery-slim.min.js"><\/script>')</script>