How work BigPipe cache around block views? I have 2 blocks with swiper.js around.

This 2 blocks are from the views module.

I need to print them in the theme like i want so, i load them into the preprocess_page.

$block1 = \Drupal\block\Entity\Block::load('views_block__test_1');
$variables['block1'] = \Drupal::entityTypeManager()
                    -&gt;getViewBuilder('block')
                    -&gt;view($block1);


And the second : 

$block2 = \Drupal\block\Entity\Block::load('views_block__test_2');
$variables['block2'] = \Drupal::entityTypeManager()
                    -&gt;getViewBuilder('block')
                    -&gt;view($block2);


They have exactly the same configuration in views and block config.

But for block 1 swipper work, not for the block2 every time i load the page.

If i look at the source i got this for the second block :

&lt;span data-big-pipe-placeholder-id="callback=Drupal%5Cblock%5CBlockViewBuilder%3A%3AlazyBuilder&amp;amp;args%5B0%5D=views_block__test_2&amp;amp;args%5B1%5D=full&amp;amp;args%5B2%5D&amp;amp;token=3_VvuYGr92bR7BowQRNlDa4VjOC0ugQafPxRFmxKk9E"&gt;&lt;/span&gt;


For the block 1 i got the HTML render.

I don't know why the second block is cached by big-pipe and not the first block.

But my js on the ready state work every time on the first block, and depend if i clear the cache but it's not everytime, work on the second block the first time i load the page.

The callback (in the bigpipe attributes) call something at the bottom of the page after the js include.

That why my second block doesn't work ? it's not clear.

What's happen ?
I don't know why the second block is cached by big-pipe and not the
  first block.


This depends on the auto placeholder conditions defined in services.yml and the cache metadata of the block:

auto_placeholder_conditions:
  # Max-age at or below which caching is not considered worthwhile.
  #
  # Disable by setting to -1.
  #
  # @default 0
  max-age: 0
  # Cache contexts with a high cardinality.
  #
  # Disable by setting to [].
  #
  # @default ['session', 'user']
  contexts: ['session', 'user']
  # Tags with a high invalidation frequency.
  #
  # Disable by setting to [].
  #
  # @default []
  tags: []


As mentioned in the comments, when the module BigPipe is enabled you need to use Drupal.behaviors for your javascript, see:

https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview