This page is work in progress. Subject to change any time.

  • use kebab (hyphen selector)
  • use js-* in class for js
  • thats it

Bootstrap CSS Selector

  • Use class only. Do not use id selector. Leave it for JavaScript
  • Use kebab case (lower case and hyphen): btn-primary, btn-danger, footer
  • Use noun followed by verb or noun followed by adverb (verb before adverb): btn-delete, btn-primary, btn-delete-danger

Bootstrap JavaScript Selector

  • Use camel case for id selector: formPost, cardImage1, imageMasonry
  • Use js-* and kebab case (lower case and hyphen) for class: js-btn-delete
  • Use noun followed by verb or noun followed by adverb (verb before adverb): js-btn-delete, js-btn-delete-danger

Pendekatan menarik untuk memisahkan selector CSS dan JavaScript

  • id hanya untuk JavaScript
  • class hanya untuk CSS
  • selector collection untuk JavaScript dapat menggunakan data-action dan data-target

https://gomakethings.com/javascript-selectors-in-html/

ho fast?

https://gomakethings.com/javascript-selector-performance/

which selector to use

https://www.freecodecamp.org/news/how-to-avoid-frustration-by-choosing-the-right-javascript-selector-73c64c3906b6/

or use data-selector instead

https://gomakethings.com/javascript-selector-strategy/