r/codesnip

Switch favicon based on color scheme
▲ 600 r/codesnip+2 crossposts

Switch favicon based on color scheme

If you've always wanted to switch your favicon based on dark/light mode, here's how to do it. I bet you already know that! 😊

Bonus: If you use an SVG favicon, you can use media queries within it to achieve the same "effect".

u/wanoo21 — 10 days ago
▲ 314 r/codesnip+1 crossposts

That will help your users avoid accidentally leaving the page

Especially when scrolling a table or a slider.

It gives you smooth, natural scrolling inside an element while protecting the rest of the page from accidental scrolling.

It's a common trick used for modals, side menus, chat boxes, or any scrollable area where you don't want the rest of the website to move when the user scrolls.

u/wanoo21 — 10 days ago
▲ 98 r/codesnip+1 crossposts

Do not sleep on AbortController

A little tip for today!

You can use `AbortController` instead of `removeListener`.

It's cleaner and easier to work with, and it can abort multiple listeners simultaneously when they share the same signal.

u/wanoo21 — 9 days ago