Using bigpipe.

To avoid blocking page loads for long-lasting API calls, etc, I implement:

$element = [
  '#lazy_builder' => ['service.admin:method', []],
  '#create_placeholder' => TRUE,

and it works great! The page loads, and once the service returns the render array, it gets popped into the placeholder.

However, the placeholder span is empty and does not provide the user with any useful status. My goal is to have the empty placeholder replaced with a message (i.e. 'Loading data..'). This is proving more difficult than I assumed - I feel like I must be missing something.

My first crack was manually defining the placeholder:

$element = [
  '#markup' => 'Loading data..',
  '#attached' => [
    'placeholders' => [
      'Loading data..' => [
        '#lazy_builder' => ['service.admin:method', []],

This generates the desired content, but blocks any elements further down of it from loading until the method returns - pausing with half the page rendered. I assume it pushes the lazy_builder into the render process where it isn't as useful for this purpose.

I skimmed through core and couldn't glean any examples of this.

Is there an easy way to add text to the placeholder? This cannot be a novel need.

Warm Regards.

1 Answer 1


I know this is an old question, but for anyone who stumbles upon it via a search engine (like I did), then the answer is that as of right now, you can't provide custom placeholder markup, but there is a Drupal.org issue with patches that adds this functionality, so it's possible that the feature will eventually be available in the Big Pipe module without a patch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.