Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Transitions and Transforms Transition Timing Functions and Delays Change a Transition's Speed with Timing Functions

JavaScript vs CSS

Hi Community,

I have a question of what is the prefer solution to create transitions. I have noticed image galleries effects can be achieved similarly with JavaScript and CSS. But is there some sort of technology preference for this? My question is most toward response efficiency, SEO affectation if any and user experience.

Thanks

1 Answer

Michael Hulet
Michael Hulet
47,869 Points

It's always best to use CSS animations and transitions if you can. This is for 3 main reasons:

  1. CSS transitions and animations are GPU accelerated, so they'll run visibly faster and smoother than JavaScript transitions and animations
  2. A user can turn off JavaScript, and they won't see your animation/transition if they do
  3. You have to write more platform-dependent code in JavaScript than CSS

Thanks really appreciated it !

peichunliu
peichunliu
33,154 Points

Thank you for the answer. Really helpful.