TIMEX TIMEX - 4 months ago 9
HTML Question

How do I include a javascript if it's IE, and another javascript if everything else?

I want to include

<script src="ie.js">
if the browser is IE.

Otherwise, include
all.js
for all other browsers.

How can I do this?

Answer

You can do this using conditional comments. Example:

<!--[if IE]>
    <script src="ie.js">
<![endif]-->
<!--[if !IE]><!-->
    <script src="all.js">
<!--<![endif]-->
Comments