Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.

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.

vrijvlinderShadowdarehgtonightR_Jbusinessdad
Sign In or Register to comment.