简体   繁体   中英

Conditional include js/css files for IE with meteor

In pure html it is common to use conditional includes like:

<!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <script src="js/ltie9.js"></script>
<![endif]-->

My ltie9.js is pretty simple

$(document).ready(function(){
    $("#ltie9").modal('show');
});

The ltie9.js is wrapped by meteor into:

<script type="text/javascript" src="/client/js/ltie9.js?dbe4ceed5fdf7ec4fd714612d501c94e5c19c04b"></script>

Wrapped as it looks now:

(function(){$(document).ready(function(){
    $("#ltie9").modal('show');
});
})();

Seems that conditional comment doesn't work as the modal occurs even if I use Chrome. How to fix that conditional statement - should I check the browser vendor and version via js? Sounds like a very heavy solution.

Any .js files in /client will simply be included in your codebase - you should not try to included them manually in the head.

To do what you're looking to do, keep the conditional comment but place the JS file in the /public folder where they will be treated as static content (and not part of your application code).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM