Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are you allowed to have an alternate source for a script?

Is is possible to have an alternate source for a javascript in HTML5? For example, I am using jQuery, and have it locally. But an I allowed to include an alt attribute so that if that doesn't work, Google's jQuery will load?

If it works, the code would look something like this: <script src="enter your text here.js" alt="googlescode"></script>

like image 492
tjons Avatar asked Sep 07 '13 19:09

tjons


1 Answers

If it is jQuery, you might want to look at this article.

Snippet:

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.0.0.min.js"></script>
<script>
    if (typeof jQuery == 'undefined') {
        document.write(unescape("%3Cscript src='/js/jquery-2.0.0.min.js' type='text/javascript'%3E%3C/script%3E"));
    }
</script>
like image 112
Álvaro Martínez Avatar answered Sep 30 '22 02:09

Álvaro Martínez