Question: Does anyone know how to check if jquery has been loaded (with javascript) then load it if it hasnt been loaded.

something like

```
if(!jQuery) {
    //load jquery file
}

```

Answer: 
Maybe something like this:

```
<script>
if(!window.jQuery)
{
   var script = document.createElement('script');
   script.type = "text/javascript";
   script.src = "path/to/jQuery";
   document.getElementsByTagName('head')[0].appendChild(script);
}
</script>

```
I am using CDN for my project and as part of fallback handling, i was using below code,

```
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript">
                if ((typeof jQuery == 'undefined')) {
                    document.write(unescape("%3Cscript src='/Responsive/Scripts/jquery-1.9.1.min.js' type='text/javascript'%3E%3C/script%3E"));   
                }
</script>

```

Just to verify, i removed CDN reference and execute the code. Its broken and it's never entered into if loop as **typeof jQuery** is coming as **function** instead of undefined .

This is because of cached older version of jquery 1.6.1 which return **function** and break my code because i am using jquery 1.9.1. As i need exact version of jquery, i modified code as below,

```
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
            if ((typeof jQuery == 'undefined') || (jQuery.fn.jquery != "1.9.1")) {
                document.write(unescape("%3Cscript src='/Responsive/Scripts/jquery-1.9.1.min.js' type='text/javascript'%3E%3C/script%3E"));   
            }
</script>

```