views:

174

answers:

7

If I have a CSS solution for all browsers except IE then what should be chosen for IE?

CSS expression in IE conditional comments

or

JavaScript in IE conditional comments

or

jQuery + plugin in IE conditional comments

Which will be less slow in rendering speed?

+1  A: 

CSS expressions only work in Internet Explorer only, so you'll have to use Javascript in some form, for complex styles. Firefox, Safari and Chrome recognise a lot of CSS3 so if you're trying to do something like rounded corners or multiple backgrounds you could use that and look for an expression equivalent for IE.

However, I would recommend using jQuery. It's built to be cross-browser, and your code will likely end up simpler than using combinations of expressions/browser-specific styles.

DisgruntledGoat
ok so cross browser compatibility is +point of jquery on all
metal-gear-solid
No. While JQ and its ilk are cross browser, you are far better using CSS wherever you could, and only using JQ when needed. For example, if you need to support rounded corners, you should use CSS to handle FF and Webkit, and JQ (if included, otherwise vanilla Javascript) just for the browsers without round corners support. It would be very poor form to apply round corners in FF using JavaSscript, although it could be done. So, in your case, you do not NEED the cross-browser benefits of JQ, you just need IE support. Including 20KB's of script for something simple is a mistake. See my answer.
SamGoody
+1  A: 

jQuery plugin, if I'm already using jQuery.
I don't think I ever used CSS expression, not even as a hack.
As for a non-jQuery JavaScript library - I'd have to learn it from scratch, it might re-implement some of jQuery's features (so doesn't benefit from jQuery's engine, cross browser, etc), and it may not be written in the convenient style of jQuery, like chaining and liberal null checks.

Kobi
+1  A: 

Updated to new focus: If you've got it looking good in everything but IE (an all too common situation...) then you need some method of writing code that only IE sees/executes. You can do this with browser sniffing in JavaScript, conditional comments in CSS and HTML. IE CSS bugs (anyone else have some good links?)

(Old answer:)

CSS expressions: Internet Explorer only shortcut.

JavaScript: Have to code every stinking thing yourself. Works "cross browser", but you still need to test in all the browsers to make sure it's doing what you want.

jQuery: cross browser, easy, simple. :D

CrazyJugglerDrummer
i edited my question
metal-gear-solid
+1  A: 

You should avoid CSS expressions.

As for JavaScript vs. jQuery, that depends. If I can do it in just a few lines of JS without cross-browser issues, and I'm not already using jQuery for other stuff, there's no reason to load the entire jQuery library. Anything much more complicated than a few document.getElementById or alert calls, though, and I'm likely to want jQuery available, and at that point I might as well be using jQuery plugins

ceejayoz
A: 
  1. Wait for Microsoft to improve IE.. haha.
  2. Ignore IE -> Encourage your web-visitors/users yo download/use a different browser (IMHO, firefox is a really, really good choice, if not the best)

There are ways of making IE 'compatible' with modern, css-stylized websites (such as the well-known comment <--[if lte IE 6]>...<[endif]--> (took the ! away, otherwise it works..) and so on.. but anyway, it's up to you.

cr0z3r
<!--[if lte IE 6]>...<![endif]--> there you go
Hobhouse
I edited my question.
metal-gear-solid
+1  A: 
  1. Do not use CSS expressions.

The reason: CSS expressions can be evaluated many hundreds of times per second. Especially considering that IE is not the fastest horse in the race, don't do that to the poor old browser. The average IE CSS expression is evaluated over one thousand times in the time the person views the page.

What's more, it is just Javascript - it doesn't work if JS is off, creates the same garbage global variables, et al. So the gain is nill, the loss is high.

  1. Do not include JQuery just for this. But if it (or Mootools etc.) is included, use them by all means.

  2. Creating your function without JQ is simple and straightforward. Just have it run on page load and resize (http://www.devarticles.com/c/a/JavaScript/OnReset-OnResize-and-Other-JavaScript-Events/1/) and that should do the trick.

Use IE conditional comments and you are even valid.

<!--[if IE]>
<script>
  var dumbIE = function (){
   //your stuff
  }
  onload=onresize=dumbIE;
</script>
<![endif]-->
SamGoody
+1  A: 

Although I strongly disrecommend using CSS expressions (is there really no "normal" CSS hack for the particular problem? doublecheck it, twice, if necessary ask question here), I would go ahead with it. This removes the risk that the your application breaks in case that the user has JS disabled. JS is at its best when used unobtrisively and in your case it is clearly not the solution.

BalusC
no no css hack is available
metal-gear-solid
Have you ever posted question here? Link please, then I'll take a look.
BalusC
I mean i want to use some properties in IE6 which are not actually not supported in IE 6 but we can enable through CSS expressions, Javascript and with jquery
metal-gear-solid