0

Hello i need to use JavaScript to load a script tag in the head of my document. The problem is i create the script element fine, but this source is not loaded once the rest of the javascript executes. Is there a better way to load the script before the rest of the JS executes?

<script>
var jQ = document.createElement('script');
    jQ.src = '../EmergencyBroadcastScripts/source/jquery-1.10.1.min.js';
    jQ.type = 'text/javascript';
    document.head.appendChild(jQ);
            $.noConflict();
            jQuery(document).ready(function () {
                jQuery('.fancybox').fancybox();
            });
    </script>

This code will produce the error "$.noConflict is not a function" because its not loading the JQ script source before it executes my code. This is my problem. Any ideas??

1 Answers1

1

Try:

jQ.onload = function () {
            $.noConflict();
            jQuery(document).ready(function () {
                jQuery('.fancybox').fancybox();
                });
            }
I don't know if it will work in this scenario but it works with images on a canvas.