Live data from Hacker News

Ask HN: Better to use Javascript or CSS

news.ycombinator.com

1–5 of 5 posts

Re: Ask HN: Better to use Javascript or CSS

#2
My approach is to do everything in CSS animations for browsers that support it, and then fall back to jQuery animations for those that don't.

CSS animations can take advantage of hardware graphics acceleration and they render very nicely on mobile browsers.

So, my answer is: both.

Re: Ask HN: Better to use Javascript or CSS

#3
Hello there,

I would have to agree with symmet, you need both. This way if a user doesn't have a recent version of Firefox, Google Chrome, Safari or Opera you can have jQuery to fall back on.

-You can use browser detection to conditionally enable jQuery scripts on page load. You can use Javascript/jQuery or a server-side script to detect exactly which browser is loading the page.

-You can also check out http://www.modernizr.com/. It adds classes to the html element which allow you to target specific browser functionality in your stylesheet.

Let me know if you need any help with that,

Good luck!

Karl

Re: Ask HN: Better to use Javascript or CSS

#4

Hello there, I would have to agree with symmet, you need both. This way if a user doesn't have a recent version of Firefox, Google Chrome, Safari or Opera you can have jQuery to fall back on. -You can use browser detection to conditionally enable jQuery scripts on page load. You can use Javascript/jQuery or a server-side script to detect exactly which browser is loading the page. -You can also check out http://www.mo…

I agree. Here's a Javascript snippet I saw recently that is a useful start for doing this (read the comments for some ideas of what you may or may not need to modify): http://www.bradshawenterprises.com/blog/2011/a-jquery-functi...