How can I refactor these script tags?
Posted
by Shpigford
on Stack Overflow
See other posts from Stack Overflow
or by Shpigford
Published on 2010-05-10T19:59:07Z
Indexed on
2010/05/10
20:04 UTC
Read the original article
Hit count: 243
JavaScript
|refactoring
I have the following script tags in the <head>
so that they don't prompt any security errors when going back and forth between SSL and non-SSL pages. But it just looks hairy.
Any way I can combine them or reduce some of the code?
<script type="text/javascript">document.write(["\<script src='",("https:" == document.location.protocol) ? "https://" : "http://","ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' type='text/javascript'>\<\/script>"].join(''));</script>
<script type="text/javascript">document.write(["\<script src='",("https:" == document.location.protocol) ? "https://" : "http://","html5shiv.googlecode.com/svn/trunk/html5.js' type='text/javascript'>\<\/script>"].join(''));</script>
<script type="text/javascript">document.write(["\<script src='",("https:" == document.location.protocol) ? "https://" : "http://","use.typekit.com/12345.js' type='text/javascript'>\<\/script>"].join(''));</script>
© Stack Overflow or respective owner