drupal-lazy-builders

Coordinate Drupal lazy builders to render dynamic content behind cacheable placeholders.

3|5|Updated Jan 8, 2026
One-click install
npx skills add https://github.com/sparkfabrik/sf-awesome-copilot --skill drupal-lazy-builders
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drupal-lazy-builders
Source: https://github.com/sparkfabrik/sf-awesome-copilot/tree/main/skills/drupal/cache/drupal-lazy-builders
Command: npx skills add https://github.com/sparkfabrik/sf-awesome-copilot --skill drupal-lazy-builders

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Drupal lazy builders enable deferring rendering of dynamic or personalized content, allowing pages to be cached while placeholders are used to replace content later.

Core Features & Use Cases

  • Lazy builders defer rendering of dynamic content inside render arrays to keep caches valid.
  • TrustedCallbackInterface support ensures secure invocation of lazy builders.
  • Auto-placeholdering with '#create_placeholder' isolates non-cacheable content and improves authenticated user performance.
  • BigPipe integration and per-user or per-session caching contexts help scale personalized experiences.

Quick Start

Create a render array item using '#lazy_builder' with a placeholder to isolate dynamic content behind a cacheable boundary.

Frequently Asked Questions about drupal-lazy-builders

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I cache dynamic content in Drupal render arrays without breaking page caching?

Use Drupal lazy builders to defer rendering dynamic content behind cacheable placeholders in render arrays. This preserves page caching while delivering personalized elements by isolating non-cacheable sections with '#lazy_builder' and '#create_placeholder'.

When should I use lazy builders instead of regular render arrays in Drupal?

Use Drupal lazy builders for pages with user-specific data, session-based content, or uncacheable sections. They isolate non-cacheable parts behind a cacheable boundary, allowing the main page to remain cached while personalized elements render independently.

Do I need TrustedCallbackInterface to implement a lazy builder in Drupal?

Yes, implementing TrustedCallbackInterface is required to securely invoke Drupal lazy builders. It ensures the callback function is explicitly trusted, preventing unauthorized code execution when deferring dynamic content rendering in render arrays.

Can I pass non-scalar arguments to a Drupal lazy builder render array?

No, Drupal lazy builders require scalar-only arguments. Passing objects or arrays as arguments breaks the placeholder generation process, preventing the system from isolating and caching the dynamic content effectively.

Does BigPipe work with Drupal lazy builders to improve authenticated user performance?

Yes, BigPipe integrates with Drupal lazy builders to stream personalized content. Combined with '#create_placeholder' and per-user caching contexts, it isolates non-cacheable content and improves authenticated user performance by sending cached page shells first.

What is the best way to isolate session-based content in a cached Drupal page?

The best way to isolate session-based content is using '#lazy_builder' with '#create_placeholder' in your Drupal render array. This defers the dynamic rendering, keeping the main page cache valid while replacing the placeholder with personalized data.