CSS Aggregation targeting specific browser version in Ektron

I have mentioned the benefits of CSS aggregation previously when using Ektron: reduce HTTP requests, reduce overall page download size and boost performance.

One thing I discovered recently was the ability to use Ektron’s CSS aggregation feature but to be able to specify a target web browser.

You have probably seen conditional comments in CSS before:

<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->

If you want to use this feature in tandem with CSS aggregation then you need these two lines of code:

Ektron.Cms.Framework.Content.ContentManager contentMgr = new Ektron.Cms.Framework.Content.ContentManager();
Ektron.Cms.API.Css.RegisterCss(this, contentMgr.SitePath + "/css/file.css", "css_file", Ektron.Cms.API.Css.BrowserTarget.IE7);

As you can see from the final parameter in the RegisterCSS() method, you can specify a target browser. In the example above I have specified IE7.

Leave a comment