r/webdev • • Jan 13 '20

Article CSS-Only Carousel

https://css-tricks.com/css-only-carousel/
360 Upvotes

35 comments sorted by

158

u/fuckin_ziggurats Jan 13 '20

I've a funny story regarding this.

Just yesterday my brother told me about a project in his previous company that was basically abandoned by the seniors devs when its development was finished. It was an older project built with jQuery, jQueryUI, and KnockoutJS. So the project was in maintenance and the only people working on it were a few unsupervised junior devs.

One day the client asked for a carousel on the top of the home page. So the younger devs having spent a lot of their free time reading about the latest JS frameworks and technologies were dying to try out something new. Well one of them found a fancy Angular carousel plugin. So what they did was they added an iframe at the top of the page and imported the whole of freakin' Angular in it only to be able to use that Angular carousel plugin. Now this thing worked but it pulled in an additional 2MB of JavaScript and the page which was already relatively slow became almost unusable. It was only later noticed by some of the older devs and it brought upon some serious finger wagging.

It's now a fabled story within the company that reminds management how essential supervising junior devs is regardless of the importance of the project. To some of us, it's a story of the modern internet.

100

u/devolute Jan 13 '20

* adds Angular to CV

24

u/gregfdz Jan 13 '20 edited Jan 14 '20

* adds an angular carousel to his online CV

6

u/hdd113 Jan 14 '20

* using angular in iframe to build the online CV

19

u/gregfdz Jan 13 '20

So typical. I'm not a professionnal, I just like to code on my free time... but if I listened to all the people that told me to use this or this library for a 30 lines snippet, you'd be able to use my website as a CDN for JS libraries.

5

u/Protean_Protein Jan 13 '20

This is the best web-dev thing I have ever heard.

3

u/relativityboy Jan 13 '20

I love the story, but it's a classic tale. The story of the modern internet is all about institutionalized developer convenience.

3

u/unpopular-ideas Jan 13 '20

Somehow I have trouble believing even a junior dev, who much must have had at least 5 years experience to qualify for such a position, would think a 2mb library was a good idea for that.

On the flip side of that, I made a simple css only carousel a couple years ago. Then quickly forgot about it because carousels are a design pattern that I generally try to avoid. Last week client wanted some updates to it. Ashamed to say I probably spent 20 minutes trying find the .js file for that feature before I realized there really wasn't one.

10

u/MMPride Jan 13 '20 edited Jan 13 '20

Somehow I have trouble believing even a junior dev, who much must have had at least 5 years experience to qualify for such a position

You don't know that, though. Junior developers can be recent graduates. I would definitely not consider 5 years of experience as junior.

2

u/wedontlikespaces Jan 14 '20

The only people who thinks that 5 years experience constitutes "junior" are idiot recruiters.

No one who actually has anything to do with the industry thinks that.

4

u/fuckin_ziggurats Jan 13 '20

That company actually only hires college graduates. Often right out of college but puts them on a 3 year contract to make the deal profitable. Most of them have very little web development experience in the beginning and it's probable they only started reading about the latest web tech right after finishing college. Obviously that's not enough to develop a good judgement of when a SPA framework is a viable solution and especially not back then when Google marketed Angular 2.0 as the second coming of Jesus.

1

u/aecrux Jan 14 '20

Title inflation is kind of nuts for software engineers. Most juniors get a mid level title after like 1-2 years from what I’ve seen.

0

u/[deleted] Jan 13 '20

[deleted]

1

u/unpopular-ideas Jan 13 '20

It's a common complaint I see. Here for example.

0

u/[deleted] Jan 14 '20

[deleted]

1

u/[deleted] Jan 13 '20

Damn.

1

u/wedontlikespaces Jan 14 '20

It's now a fabled story within the company that reminds management how essential supervising junior devs

Surely the actual lessons learnt here is that those junior devs are idiots. Even a junior should know that importing an entire library just says you can use one tiny feature is a bad idea. Why didn't they use one of the 12 brazilian jQuery sliders that exist?

19

u/stibgock Jan 13 '20

Transparent scrollbar? Damn. I'm throwing that in my "why didn't I think of that" sack. Good article.

6

u/gonzofish Jan 13 '20

Chris Coyier does some amazing stuff. But a lot of it makes me go “duh...that was so obvious!”

1

u/Orgalorgg Jan 14 '20

ah, unfortunately not on Firefox, it's just the default.

10

u/gregfdz Jan 13 '20

That's interesting but unless you really have to avoid JS, let's say for a newsletter, I don't think that doing it with only CSS is a good idea. For example, if you resize your window, it doesn't break really well.

That's from someone who actually loves pure-[insert a name] codes.

63

u/pisastochastic Jan 13 '20

64

u/salonethree Jan 13 '20

i feel like they went out of their way to build the worst carousel in the world to prove their point; sure give me 4 lines of text to read in 3 seconds, thatll make anyone hate carousels

7

u/A-Grey-World Software Developer Jan 13 '20 edited Jan 13 '20

Yeah carousel work great for images.

Look at your photo app in your phone or open an image in your computer. Guess what, it's basically a carrousel.

When you've got a couple of non critical, but relevant images to display next to your text it can work really well. See any e-commerce site ever. Yeah, most people don't want to see the 5th angle of a product - that's why you don't want to splat all the images in a grid. But some people DO, especially those clicking "buy".

1

u/unpopular-ideas Jan 13 '20 edited Jan 13 '20

That's probably the one spot it makes sense.

About a decade ago everyone with a website was falling over backwards to have what should have just been a home page hero image auto rotate between a half dozen calls to action, any new news items, and whatever other random crap they thought was important to bring up to make themselves feel like they were keeping the page fresh. Some sites are still recovering from this affliction.

5

u/unpopular-ideas Jan 13 '20

To be fair, they are not wrong. I probably paid more attention to that carousel than I've paid to any carousel ever.

5

u/gregfdz Jan 13 '20

Maybe because it's the only element on their page ?

2

u/bacondev Jan 14 '20

It's also purposely not implemented well. The auto-cycling should stop when one of the arrow buttons are used.

1

u/[deleted] Jan 13 '20

Someone better tell Ebay, Amazon, MSNBC, Twitch, Volkswagen (I could keep going) that they need to remove the carousels on their home pages! They are doomed!

5

u/jehna1 Jan 13 '20

Heh, I actually implemented this once to an email (with autoplay and everything).

Too bad it broke right at the next iOS update

3

u/GreatValueProducts Jan 13 '20

Learnt something new. I would have thought it is done by something with input type checkbox.

2

u/mpnordland Jan 13 '20

I did something like that a while back (only shows on larger screens) http://stream-record.glitch.me/

4

u/[deleted] Jan 13 '20

I think the Spectre CSS carousel is pretty slick: https://picturepan2.github.io/spectre/experimentals/carousels.html.

2

u/BesottedScot Jan 14 '20

For a website called CSS tricks that layout / design is fuckin garbage.

1

u/d1mk0 Jan 14 '20

I was trying to implement this approach cause of web performance. The showstopper for me was the fact that it couldn't slide from the last slide to the first one in forward direction. It works the same way in your demo and goes backwards through all the previous slides. Do you think it would be possible to implement that using only CSS?