Skip to main content

Core Principles

Horizon is built on four foundational principles that should guide all development work:

Web-Native Development

Leverage modern web standards while maintaining backwards compatibility Horizon runs on the evergreen web, utilizing the latest browser features while supporting older browsers through progressive enhancement.
Do not use polyfills. Use progressive enhancement and feature detection instead.

Lean and Fast

Functionality defaults to “no” until it meets performance requirements
  • Ship code based on quality, not quantity
  • Build with purpose - don’t support every feature
  • Optimize for Core Web Vitals (LCP, FID, CLS)
  • Keep JavaScript bundles minimal

Server-Rendered

HTML must be rendered by Shopify servers using Liquid Business logic and platform primitives belong on the server:

Functional Design

Functional across browsers, not pixel-perfect
  • Use semantic markup
  • Embrace progressive enhancement
  • Design for flexibility, not rigid pixel perfection
  • Test across multiple browsers and devices

Development Practices

File Organization

Store reusable, configurable content blocks in /sections/:
  • Use schema to define customization options
  • Keep sections focused on a single purpose
  • Use theme blocks for modular content
  • Follow naming convention: main-*.liquid for template sections
Store reusable Liquid code in /snippets/:
  • Keep snippets small and focused
  • Use descriptive names that indicate purpose
  • Document required parameters in comments
  • Prefix utility snippets with util-
Organize assets by type:
  • *.css - Stylesheets (prefer modern CSS over preprocessors)
  • *.js - JavaScript modules
  • Images - Optimized and properly sized
  • Fonts - Use Shopify’s font library when possible
/config/ contains:
  • settings_schema.json - Theme settings definition
  • settings_data.json - Theme settings values (don’t commit in Git)

Liquid Best Practices

JavaScript Best Practices

CSS Best Practices

Performance Optimization

Image Optimization

JavaScript Performance

  • Defer non-critical JavaScript: Use defer attribute on script tags
  • Code splitting: Load features only when needed
  • Minimize DOM manipulation: Batch updates and use DocumentFragment
  • Debounce expensive operations: Use debounce for scroll/resize handlers

CSS Performance

  • Critical CSS inline: Inline above-the-fold CSS
  • Avoid @import: Use link tags or bundle CSS
  • Minimize specificity: Keep selectors simple
  • Use CSS containment: Apply contain property where appropriate

Accessibility

Use proper HTML elements:
Enhance accessibility with ARIA:
Ensure all interactive elements are keyboard accessible:
  • Use native buttons and links when possible
  • Implement proper focus management
  • Provide visible focus indicators
  • Support keyboard shortcuts (Escape to close modals)
Maintain WCAG AA compliance:
  • Text: minimum 4.5:1 contrast ratio
  • Large text: minimum 3:1 contrast ratio
  • Interactive elements: 3:1 contrast ratio
  • Use tools to verify contrast ratios

Testing

Theme Check

Run Theme Check before committing changes:
Horizon includes Theme Check in the VS Code extensions. Install it for real-time linting.

Browser Testing

Test across multiple browsers:
  • Chrome/Edge (Chromium)
  • Firefox
  • Safari (macOS and iOS)
  • Mobile browsers

Accessibility Testing

  • Keyboard navigation: Tab through the entire page
  • Screen readers: Test with VoiceOver (macOS) or NVDA (Windows)
  • Automated tools: Use Lighthouse, axe DevTools
  • Color contrast: Use browser DevTools or online checkers

Performance Testing

  • Lighthouse: Run audits in Chrome DevTools
  • WebPageTest: Test from different locations and connections
  • Core Web Vitals: Monitor LCP, FID, CLS

Version Control

Git Workflow

What to Commit

Do commit:
  • Theme files (sections, snippets, templates, layouts)
  • Assets (CSS, JS, images)
  • Configuration schema (settings_schema.json)
  • Documentation
Don’t commit:
  • settings_data.json (contains store-specific data)
  • .DS_Store or OS-specific files
  • Node modules or dependencies
  • Generated files

Security

Never expose sensitive data in theme code. Use Shopify’s secure APIs for handling customer data.

Input Sanitization

Content Security

  • Use {{ content_for_header }} for required Shopify scripts
  • Avoid inline JavaScript when possible
  • Validate and sanitize all form inputs
  • Use HTTPS for all external resources

Documentation

Code Comments

Schema Documentation

Resources