HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Conditional comment scripts the vanilla way

x00x00 MVP
edited May 2014 in Tutorials

Often you see hard coded in theme's default.master stuff like

<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

However this not adding resources the vanilla way. In your themehooks file you can do it like so

    //IE only
    $Sender->Head->AddScript("https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js", 'text/javascript', array('ie'=>'lt IE 9'));
    $Sender->Head->AddScript("https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js", 'text/javascript', array('ie'=>'lt IE 9'));

grep is your friend.

Sign In or Register to comment.