0

I want to load a custom script on a page from a different domain. I do it as:

<script type="text/javascript">
(function(d){
  var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');
  p.type = 'text/javascript';
  p.async = true;
  p.src = '//domainA.com/js/custom.js';
  f.parentNode.insertBefore(p, f);
}(document));
</script>

My custom.js script uses JQuery as well as Ajax to load additional content.

How do I check if jquery is on the page and load it before the script custom.js is excecuted?

How can I ensure that cross-site ajax requests work in the custom.js script?

Michael
  • 32,527
  • 49
  • 210
  • 370

0 Answers0