Skip to main content

Clean Code & Maintainability

The website you launch is rarely the last version. Building it so it's easy to change later — by you or the next person — saves far more time than it costs.

The habits

  • Keep the DOM clean. Every extra nested <div> is more to render, more for a screen reader to wade through, and more to style. Favour semantic elements and the least nesting that works.
  • Name things clearly and consistently. Good names are documentation. Prefix anything shared globally (CSS classes, functions) so it can't collide with other code.
  • Never edit the parent theme. Customise in a child theme so a theme update doesn't wipe your changes.
  • Reuse a design system. Set colours, fonts and spacing once (in Theme Settings) and reference them, instead of hard-coding a hex value in fifty places — then a rebrand is one change, not fifty.
  • Don't repeat yourself (DRY). If you're copy-pasting the same block, make it reusable (a Snippet, a template) so there's a single source of truth.

In UnysonPlus

The framework is built around these ideas: a clean, semantic DOM; a central design system in Theme Settings; reusable Snippets and templates; and a child-theme workflow that survives updates.

Learn more: MDN: CSS specificity · Clean DOM in the Page Builder