Skip to content
Kyle Hotchkiss edited this page Feb 5, 2016 · 3 revisions

Javascript

Checking if element exists

if ( $('.element').length ) {
    // code here
}

Error Handling

  • We should account for errors at any point in the code where things are likely to go wrong
  • We should bubble errors back up end user gracefully. The process should never crash for most errors
  • We should send the error to sentry
  • Only use try/catch patterns if the parent library won't pass errors in callbacks.

Twig/Timber

Spacing

Keep a space between brackets and variable names: {{ variable }} not {{variable}}

When you need a one-off page template, page styles, or page ACF, use the template-* prefix.

  1. When ACF ties fields to a page, it ties it to the numeric ID. This is fragile.

  2. Users will often duplicate a page and run it off a different URL to try things out.


For twitter or other social links, use url_encode instead of e(url)

needs cite