Best Practices
Coding standards and performance optimization guidelines
Coding Standards
File Naming
Use kebab-case for all files: my-file-name.html. This improves readability and works across all file systems.
CSS Organization
Use CSS variables for theming. Group related styles together. Follow BEM naming for component styles.
JavaScript Best Practices
Use const/let instead of var. Prefer arrow functions. Minimize global variables. Use semantic function names.
HTML Semantics
Use appropriate semantic elements. Include required meta tags. Set lang attribute correctly for i18n.
Performance Tips
Lazy Loading
Load images and scripts only when needed. Use loading="lazy" for images and dynamic imports for JS modules.
Optimize Images
Use WebP format when possible. Compress images. Specify width/height to avoid layout shifts.
Minimize Reflows
Batch DOM changes. Use CSS transforms instead of layout properties. Cache layout measurements.
Use CDN Wisely
Use reliable CDNs with multiple fallback options. Consider self-hosting critical resources.