<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/sources/30seconds/best-of/2023/11" -->

---
title: Best 30 seconds of code posts — November 2023 | daily.dev
description: The most upvoted 30 seconds of code posts from November 2023, curated by the daily.dev community.
canonical: https://daily.dev/sources/30seconds/best-of/2023/11
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:url: https://daily.dev/sources/30seconds/best-of/2023/11
og:type: website
og:site_name: daily.dev
og:title: Best 30 seconds of code posts — November 2023 | daily.dev
og:description: The most upvoted 30 seconds of code posts from November 2023, curated by the daily.dev community.
og:image: https://media.daily.dev/image/upload/s--VAY5ToZt--/f_auto/v1724209435/public/daily.dev%20-%20open%20graph
---

# Best of 30 seconds of code — November 2023

1. 1  
[](https://daily.dev/posts/use-data-attributes-instead-of-html-classes-to-represent-state-uxu6l5ghw "Use data attributes instead of HTML classes to represent state")  
Article  
![Avatar of 30seconds](https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/197d6538eea141d7a2fb4177234e9d89)30 seconds of code · 3y  
Use data attributes instead of HTML classes to represent state  
Representing UI state in HTML using data attributes is more flexible and scalable than using classes. It allows for explicit and debuggable representation of state, and avoids problems with conflicting styles.  
21  
1
2. 2  
[](https://daily.dev/posts/how-can-i-listen-for-an-event-only-once-in-javascript--pvk10yvku "How can I listen for an event only once in JavaScript?")  
Article  
![Avatar of 30seconds](https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/197d6538eea141d7a2fb4177234e9d89)30 seconds of code · 3y  
How can I listen for an event only once in JavaScript?  
Learn how to listen for an event only once in JavaScript using event listener options, a flag-based implementation, or jQuery's one() method.  
14  
1

[See all 30 seconds of code archives](/sources/30seconds/best-of)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@graph":[{"@type":"CollectionPage","@id":"https://daily.dev/sources/30seconds/best-of/2023/11#page","url":"https://daily.dev/sources/30seconds/best-of/2023/11","name":"Best 30 seconds of code Posts — November 2023","description":"The most upvoted 30 seconds of code posts from November 2023, curated by the daily.dev community.","isPartOf":{"@type":"WebSite","url":"https://daily.dev"}},{"@type":"ItemList","@id":"https://daily.dev/sources/30seconds/best-of/2023/11#items","numberOfItems":2,"itemListElement":[{"@type":"ListItem","position":1,"url":"https://daily.dev/posts/use-data-attributes-instead-of-html-classes-to-represent-state-uxu6l5ghw","name":"Use data attributes instead of HTML classes to represent state"},{"@type":"ListItem","position":2,"url":"https://daily.dev/posts/how-can-i-listen-for-an-event-only-once-in-javascript--pvk10yvku","name":"How can I listen for an event only once in JavaScript?"}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Sources","item":"https://daily.dev/sources"},{"@type":"ListItem","position":3,"name":"30 seconds of code","item":"https://daily.dev/sources/30seconds"},{"@type":"ListItem","position":4,"name":"Best of","item":"https://daily.dev/sources/30seconds/best-of"},{"@type":"ListItem","position":5,"name":"November 2023"}]}]}
```

