Graphite Reviewer is now Diamond

Best practices for reviewing front-end code

Sara Verdi
Sara Verdi
Graphite software engineer
Try Graphite

Reviewing front-end code effectively requires attention to detail and an understanding of best practices across HTML, CSS, and JavaScript. Leveraging tools like the Graphite PR inbox can also help streamline the process by organizing and prioritizing pull requests. This guide will explore these best practices, starting with:

Semantic HTML enhances accessibility and SEO while making the code easier to understand. Look for:

  • Proper use of semantic tags like <header>, <footer>, <main>, <article>, and <section>.
  • Avoidance of excessive <div> or <span> tags when more meaningful elements exist.
  • ARIA roles where necessary for screen reader compatibility.

Tip: Use the Graphite PR inbox’s needs your review section to prioritize PRs with significant HTML updates.

CSS should be modular, maintainable, and efficient. For example:

  • Use classes over IDs for styling to avoid specificity issues.
  • Follow a consistent naming convention like BEM (Block Element Modifier).
  • Ensure styles are scoped correctly to avoid unintended side effects.
  • Optimize media queries for responsive design.

Tip: Graphite’s PR Inbox "returned to you" section can highlight PRs that require additional adjustments, ensuring iterative improvements to CSS quality.

JavaScript is often the backbone of interactive features. Reviewers should focus on:

  • Avoiding inline JavaScript in HTML for better separation of concerns.
  • Ensuring proper use of modern ES6+ features like let and const instead of var.
  • Validating that logic is broken into smaller, reusable functions.
  • Checking for error handling in asynchronous code.

Front-end code must work across all supported browsers. During reviews, confirm:

  • Use of vendor prefixes when necessary (e.g., -webkit- for older browsers).
  • Compliance with web standards like W3C.
  • Inclusion of polyfills or fallbacks for unsupported features.

Tip: Graphite’s PR Inbox "drafts" section allows reviewers to assess PRs still in progress and provide feedback before they are finalized.

Accessibility is a critical aspect of front-end development. Developers must ensure:

  • Sufficient color contrast between text and background.
  • Keyboard navigation of interactive elements.
  • Use of alt attributes for images.
  • Avoidance of non-descriptive link text like "click here."

Tip: Share custom Graphite PR Inbox filters with your team to track accessibility-focused PRs.

Efficient front-end code leads to faster load times and better user experience. Developers should focus on:

  • Minimized and concatenated CSS and JavaScript files.
  • Use of image optimization techniques, such as WebP formats.
  • Proper JavaScript loading to prevent render-blocking execution.

Tip: Use Graphite's PR Inbox to create custom sections that track PRs labeled as needing performance optimizations.

The Graphite PR Inbox organizes pull requests into intuitive sections like "needs your review" and "waiting for review" to help streamline your code review workflow. With the PR inbox, you can:

  • Customize sections to filter front-end specific PRs, such as those tagged with #HTML, #CSS, or #JavaScript.
  • Use the fuzzy search feature to quickly find PRs by title, description, or author.
  • Share filter configurations to maintain consistency across team members reviewing front-end code.

For example, you can create a custom section to highlight PRs with accessibility or performance tags for more focused front-end code reviews.

screenshot of adding a custom section to the PR inbox

By following these best practices and leveraging tools like Graphite’s PR Inbox, you can improve the quality, maintainability, and user experience of front-end code.

Built for the world's fastest engineering teams, now available for everyone