How to use it
- Select the element and open its Conditions.
- Add the condition Device from the Kiln group.
- Choose is or is not.
- Pick the device: Mobile phone, Tablet, Phone or tablet or Desktop.
Use it to leave heavy or irrelevant markup out of the page, such as a video hero on phones or a desktop mega menu. For layout changes alone, Bricks' breakpoint controls are cheaper.
How it works
Kiln reads the visitor's user agent. If a CDN sends a CF-Device-Type header (Cloudflare's "Cache by device
type"), Kiln uses that value instead. It sorts the request into mobile, tablet or desktop:
- Smart TVs, Android TV, Google TV and Fire TV count as desktop.
- Tablets are matched before phones, so an Android tablet is a tablet and an Android phone is a phone.
- Phone or tablet matches anything that is not desktop.
A developer can override the result with the kiln/device filter. It receives mobile, tablet or desktop
and must return one of the three.
Compared with the Operating system condition
The Operating system condition in Bricks can only be combined per OS with OR, and it cannot tell an Android phone from an Android tablet. This condition can.
How it works with page caches
The result differs per device, so a page that checks it cannot come from one shared cache. When the page
evaluates a Device condition, Kiln tells page-cache plugins not to cache it (the DONOTCACHEPAGE constant, the
LiteSpeed Cache no-cache call, and no-cache headers when they have not been sent yet).
A cache at the host or CDN level, such as nginx, Varnish or Cloudflare "cache everything", only sees the response headers. Those are usually sent before Bricks renders the page. Make that cache vary by device, or exclude the page, or one device's version is served to everyone.
Limits
- iPadOS 13 and newer, and Chrome on large Android tablets, ask websites for the desktop version. Kiln counts them as desktop.
- Googlebot crawls as a phone. Content you show to desktops only is not indexed.
Settings
None. Turn the module on in Bricks > Kiln (it is on by default).
Requirements
Bricks 2.4 or newer.