diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php
index 7d36b51..69a8f13 100644
--- a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php
+++ b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php
@@ -148,6 +148,16 @@ protected function buildAttachmentsCommands(AjaxResponse $response, Request $req
     $css_assets = $this->assetResolver->getCssAssets($assets, $optimize_css);
     list($js_assets_header, $js_assets_footer) = $this->assetResolver->getJsAssets($assets, $optimize_js);
 
+    // First, AttachedAssets::setLibraries() ensures duplicate libraries are
+    // removed: it converts it to a set of libraries if necessary. Second,
+    // AssetResolver::getJsSettings() ensures $assets contains the final set of
+    // JavaScript settings. AttachmentsResponseProcessorInterface also mandates
+    // that the response it processes contains the final attachment values, so
+    // update both the 'library' and 'drupalSettings' attachments accordingly.
+    $attachments['library'] = $assets->getLibraries();
+    $attachments['drupalSettings'] = $assets->getSettings();
+    $response->setAttachments($attachments);
+
     // Render the HTML to load these files, and add AJAX commands to insert this
     // HTML in the page. Settings are handled separately, afterwards.
     $settings = [];
diff --git a/core/lib/Drupal/Core/Asset/AssetResolver.php b/core/lib/Drupal/Core/Asset/AssetResolver.php
index 9927049..a533c8a 100644
--- a/core/lib/Drupal/Core/Asset/AssetResolver.php
+++ b/core/lib/Drupal/Core/Asset/AssetResolver.php
@@ -334,6 +334,9 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) {
       // Allow modules and themes to alter the JavaScript settings.
       $this->moduleHandler->alter('js_settings', $settings, $assets);
       $this->themeManager->alter('js_settings', $settings, $assets);
+      // Update the $assets object accordingly, so that it reflects the final
+      // settings.
+      $assets->setSettings($settings);
       $settings_as_inline_javascript = [
         'type' => 'setting',
         'group' => JS_SETTING,
diff --git a/core/lib/Drupal/Core/Asset/AssetResolverInterface.php b/core/lib/Drupal/Core/Asset/AssetResolverInterface.php
index c912d76..e0845c6 100644
--- a/core/lib/Drupal/Core/Asset/AssetResolverInterface.php
+++ b/core/lib/Drupal/Core/Asset/AssetResolverInterface.php
@@ -69,6 +69,8 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize);
    *
    * @param \Drupal\Core\Asset\AttachedAssetsInterface $assets
    *   The assets attached to the current response.
+   *   Note that this object is modified to reflect the final JavaScript
+   *   settings assets.
    * @param bool $optimize
    *   Whether to apply the JavaScript asset collection optimizer, to return
    *   optimized JavaScript asset collections rather than an unoptimized ones.
diff --git a/core/lib/Drupal/Core/Render/AttachmentsResponseProcessorInterface.php b/core/lib/Drupal/Core/Render/AttachmentsResponseProcessorInterface.php
index 6067a86..74614ee 100644
--- a/core/lib/Drupal/Core/Render/AttachmentsResponseProcessorInterface.php
+++ b/core/lib/Drupal/Core/Render/AttachmentsResponseProcessorInterface.php
@@ -46,7 +46,8 @@
    *   The response to process.
    *
    * @return \Drupal\Core\Render\AttachmentsInterface
-   *   The processed response.
+   *   The processed response, with the attachments updated to reflect their
+   *   final values.
    *
    * @throws \InvalidArgumentException
    *   Thrown when the $response parameter is not the type of response object
diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
index e0160d1..69e3a4b 100644
--- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
+++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
@@ -9,6 +9,7 @@
 use Drupal\Core\Asset\AssetCollectionRendererInterface;
 use Drupal\Core\Asset\AssetResolverInterface;
 use Drupal\Core\Asset\AttachedAssets;
+use Drupal\Core\Asset\AttachedAssetsInterface;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Form\EnforcedResponseException;
 use Drupal\Core\Extension\ModuleHandlerInterface;
@@ -141,9 +142,10 @@ public function processAttachments(AttachmentsInterface $response) {
     $attached = $response->getAttachments();
 
     // Send a message back if the render array has unsupported #attached types.
+    // @todo This needs to be configurable somehow.
     $unsupported_types = array_diff(
       array_keys($attached),
-      ['html_head', 'feed', 'html_head_link', 'http_header', 'library', 'html_response_attachment_placeholders', 'placeholders', 'drupalSettings']
+      ['html_head', 'feed', 'html_head_link', 'http_header', 'library', 'html_response_attachment_placeholders', 'placeholders', 'drupalSettings', 'big_pipe_placeholders']
     );
     if (!empty($unsupported_types)) {
       throw new \LogicException(sprintf('You are not allowed to use %s in #attached.', implode(', ', $unsupported_types)));
@@ -155,7 +157,19 @@ public function processAttachments(AttachmentsInterface $response) {
       $attachment_placeholders = $attached['html_response_attachment_placeholders'];
       unset($attached['html_response_attachment_placeholders']);
 
-      $variables = $this->processAssetLibraries($attached, $attachment_placeholders);
+      $assets = AttachedAssets::createFromRenderArray(['#attached' => $attached]);
+      // Take Ajax page state into account, to allow for something like
+      // Turbolinks to be implemented without altering core.
+      // @see https://github.com/rails/turbolinks/
+      $ajax_page_state = $this->requestStack->getCurrentRequest()->get('ajax_page_state');
+      $assets->setAlreadyLoadedLibraries(isset($ajax_page_state) ? explode(',', $ajax_page_state['libraries']) : []);
+      $variables = $this->processAssetLibraries($assets, $attachment_placeholders);
+      // $variables now contains the markup to load the asset libraries. Update
+      // $attached with the final list of libraries and JavaScript settings, so
+      // that $response can be updated with those. Then the response object will
+      // list the final, processed attachments.
+      $attached['library'] = $assets->getLibraries();
+      $attached['drupalSettings'] = $assets->getSettings();
 
       // Since we can only replace content in the HTML head section if there's a
       // placeholder for it, we can safely avoid processing the render array if
@@ -168,6 +182,7 @@ public function processAttachments(AttachmentsInterface $response) {
             $attached,
             $this->processFeed($attached['feed'])
           );
+          unset($attached['feed']);
         }
         // 'html_head_link' is a special case of 'html_head' which can be present
         // as a head element, but also as a Link: HTTP header depending on
@@ -182,6 +197,7 @@ public function processAttachments(AttachmentsInterface $response) {
             $attached,
             $this->processHtmlHeadLink($attached['html_head_link'])
           );
+          unset($attached['html_head_link']);
         }
 
         // Now we can process 'html_head', which contains both 'feed' and
@@ -200,6 +216,10 @@ public function processAttachments(AttachmentsInterface $response) {
       $this->setHeaders($response, $attached['http_header']);
     }
 
+    // AttachmentsResponseProcessorInterface mandates that the response it
+    // processes contains the final attachment values.
+    $response->setAttachments($attached);
+
     return $response;
   }
 
@@ -255,8 +275,8 @@ protected function renderPlaceholders(HtmlResponse $response) {
   /**
    * Processes asset libraries into render arrays.
    *
-   * @param array $attached
-   *   The attachments to process.
+   * @param \Drupal\Core\Asset\AttachedAssetsInterface $assets
+   *   The attached assets collection for the current response.
    * @param array $placeholders
    *   The placeholders that exist in the response.
    *
@@ -266,16 +286,7 @@ protected function renderPlaceholders(HtmlResponse $response) {
    *     - scripts
    *     - scripts_bottom
    */
-  protected function processAssetLibraries(array $attached, array $placeholders) {
-    $all_attached = ['#attached' => $attached];
-    $assets = AttachedAssets::createFromRenderArray($all_attached);
-
-    // Take Ajax page state into account, to allow for something like Turbolinks
-    // to be implemented without altering core.
-    // @see https://github.com/rails/turbolinks/
-    $ajax_page_state = $this->requestStack->getCurrentRequest()->get('ajax_page_state');
-    $assets->setAlreadyLoadedLibraries(isset($ajax_page_state) ? explode(',', $ajax_page_state['libraries']) : []);
-
+  protected function processAssetLibraries(AttachedAssetsInterface $assets, array $placeholders) {
     $variables = [];
 
     // Print styles - if present.
diff --git a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php
index e0940bf..51d7c77 100644
--- a/core/lib/Drupal/Core/Render/PlaceholderGenerator.php
+++ b/core/lib/Drupal/Core/Render/PlaceholderGenerator.php
@@ -80,6 +80,8 @@ public function createPlaceholder(array $element) {
       // The cacheability metadata for the placeholder. The rendered result of
       // the placeholder may itself be cached, if [#cache][keys] are specified.
       '#cache' => TRUE,
+      // The options for creating the placeholder. (optional)
+      '#create_placeholder_options' => TRUE,
     ]);
 
     // Generate placeholder markup. Note that the only requirement is that this
diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php
index b1f7c2a..c1cbc0a 100644
--- a/core/lib/Drupal/Core/Render/Renderer.php
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -158,24 +158,9 @@ public function renderPlain(&$elements) {
   }
 
   /**
-   * Renders final HTML for a placeholder.
-   *
-   * Renders the placeholder in isolation.
-   *
-   * @param string $placeholder
-   *   An attached placeholder to render. (This must be a key of one of the
-   *   values of $elements['#attached']['placeholders'].)
-   * @param array $elements
-   *   The structured array describing the data to be rendered.
-   *
-   * @return array
-   *   The updated $elements.
-   *
-   * @see ::replacePlaceholders()
-   *
-   * @todo Make public as part of https://www.drupal.org/node/2469431
+   * {@inheritdoc}
    */
-  protected function renderPlaceholder($placeholder, array $elements) {
+  public function renderPlaceholder($placeholder, array $elements) {
     // Get the render array for the given placeholder
     $placeholder_elements = $elements['#attached']['placeholders'][$placeholder];
 
@@ -196,7 +181,6 @@ protected function renderPlaceholder($placeholder, array $elements) {
     return $elements;
   }
 
-
   /**
    * {@inheritdoc}
    */
@@ -341,6 +325,7 @@ protected function doRender(&$elements, $is_root_call = FALSE) {
         '#lazy_builder',
         '#cache',
         '#create_placeholder',
+        '#create_placeholder_options',
         // These keys are not actually supported, but they are added automatically
         // by the Renderer, so we don't crash on them; them being missing when
         // their #lazy_builder callback is invoked won't surprise the developer.
@@ -647,6 +632,8 @@ protected function setCurrentRenderContext(RenderContext $context = NULL) {
    *
    * @returns bool
    *   Whether placeholders were replaced.
+   *
+   * @see ::renderPlaceholder()
    */
   protected function replacePlaceholders(array &$elements) {
     if (!isset($elements['#attached']['placeholders']) || empty($elements['#attached']['placeholders'])) {
diff --git a/core/lib/Drupal/Core/Render/RendererInterface.php b/core/lib/Drupal/Core/Render/RendererInterface.php
index ff04d86..ccbe2d5 100644
--- a/core/lib/Drupal/Core/Render/RendererInterface.php
+++ b/core/lib/Drupal/Core/Render/RendererInterface.php
@@ -67,6 +67,24 @@ public function renderRoot(&$elements);
   public function renderPlain(&$elements);
 
   /**
+   * Renders final HTML for a placeholder.
+   *
+   * Renders the placeholder in isolation.
+   *
+   * @param string $placeholder
+   *   An attached placeholder to render. (This must be a key of one of the
+   *   values of $elements['#attached']['placeholders'].)
+   * @param array $elements
+   *   The structured array describing the data to be rendered.
+   *
+   * @return array
+   *   The updated $elements.
+   *
+   * @see ::render()
+   */
+  public function renderPlaceholder($placeholder, array $elements);
+
+  /**
    * Renders HTML given a structured array tree.
    *
    * Renderable arrays have two kinds of key/value pairs: properties and
diff --git a/core/lib/Drupal/Core/StackMiddleware/Session.php b/core/lib/Drupal/Core/StackMiddleware/Session.php
index e0ed0e4..e42f1a7 100644
--- a/core/lib/Drupal/Core/StackMiddleware/Session.php
+++ b/core/lib/Drupal/Core/StackMiddleware/Session.php
@@ -59,13 +59,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
       $request->setSession($session);
     }
 
-    $result = $this->httpKernel->handle($request, $type, $catch);
-
-    if ($type === self::MASTER_REQUEST && $request->hasSession()) {
-      $request->getSession()->save();
-    }
-
-    return $result;
+    return $this->httpKernel->handle($request, $type, $catch);
   }
 
 }
diff --git a/core/modules/big_pipe/big_pipe.info.yml b/core/modules/big_pipe/big_pipe.info.yml
new file mode 100644
index 0000000..b0f6e91
--- /dev/null
+++ b/core/modules/big_pipe/big_pipe.info.yml
@@ -0,0 +1,6 @@
+name: BigPipe
+type: module
+description: 'Enables BigPipe for authenticated users; first send+render the cheap parts of the page, then the expensive parts.'
+package: Core
+version: VERSION
+core: 8.x
diff --git a/core/modules/big_pipe/big_pipe.libraries.yml b/core/modules/big_pipe/big_pipe.libraries.yml
new file mode 100644
index 0000000..88ecff6
--- /dev/null
+++ b/core/modules/big_pipe/big_pipe.libraries.yml
@@ -0,0 +1,11 @@
+big_pipe:
+  version: VERSION
+  js:
+    js/big_pipe.js: {}
+  drupalSettings:
+    bigPipePlaceholders: []
+  dependencies:
+    - core/jquery
+    - core/drupal
+    - core/drupal.ajax
+    - core/drupalSettings
diff --git a/core/modules/big_pipe/big_pipe.module b/core/modules/big_pipe/big_pipe.module
new file mode 100644
index 0000000..f2615e6
--- /dev/null
+++ b/core/modules/big_pipe/big_pipe.module
@@ -0,0 +1,56 @@
+<?php
+
+/**
+ * @file
+ * Enables BigPipe for authenticated users; first send+render the cheap parts
+ * of the page, then the expensive parts.
+ *
+ * BigPipe allows to send a page in chunks. First the main content is sent and
+ * then uncacheable data that takes long to generate.
+ */
+
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Render\Markup;
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function big_pipe_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
+  // Check if the user has JavaScript enabled without adding JavaScript.
+  $form['big_pipe_has_js'] = array(
+    '#type' => 'hidden',
+    '#default_value' => '1',
+  );
+
+  $form['#after_build'][] = 'big_pipe_form_after_build';
+  $form['#submit'][] = 'big_pipe_form_set_js_check';
+}
+
+/**
+ * After build handler for user_login_form().
+ */
+function big_pipe_form_after_build($form, FormStateInterface $form_state) {
+  // This is tricky: we want Form API to 'default big_pipe_has_js' to '1' in
+  // case it is not sent. We also want to set the value of the HTML element
+  // to '0' and wrap it in a <noscript> tag.
+  // So in case the user has JavaScript disabled, the <noscript> is parsed and
+  // 'big_pipe_has_js' is sent with '0', else it is not sent and Form API falls
+  // back to the default value, which is '1'.
+  $form['big_pipe_has_js']['#value'] = '0';
+  $form['big_pipe_has_js']['#prefix'] = Markup::create('<noscript>');
+  $form['big_pipe_has_js']['#suffix'] = Markup::create('</noscript>');
+  return $form;
+}
+
+/**
+ * Form submission handler for user_login_form().
+ *
+ * Remember whether the user has JavaScript enabled in this session.
+ */
+function big_pipe_form_set_js_check($form, FormStateInterface $form_state) {
+  $current_user = \Drupal::currentUser();
+
+  if ($current_user->isAuthenticated()) {
+    $_SESSION['big_pipe_has_js'] = $form_state->getValue('big_pipe_has_js') == 1;
+  }
+}
diff --git a/core/modules/big_pipe/big_pipe.services.yml b/core/modules/big_pipe/big_pipe.services.yml
new file mode 100644
index 0000000..6e82d5c
--- /dev/null
+++ b/core/modules/big_pipe/big_pipe.services.yml
@@ -0,0 +1,14 @@
+services:
+  html_response.big_pipe_subscriber:
+    class: Drupal\big_pipe\EventSubscriber\HtmlResponseBigPipeSubscriber
+    tags:
+      - { name: event_subscriber }
+    arguments: ['@big_pipe']
+  placeholder_strategy.big_pipe:
+    class: Drupal\big_pipe\Render\Placeholder\BigPipeStrategy
+    tags:
+      - { name: placeholder_strategy, priority: 0 }
+    arguments: ['@current_user']
+  big_pipe:
+    class: Drupal\big_pipe\Render\BigPipe
+    arguments: ['@renderer', '@ajax_response.attachments_processor', '@html_response.attachments_processor']
diff --git a/core/modules/big_pipe/js/big_pipe.js b/core/modules/big_pipe/js/big_pipe.js
new file mode 100644
index 0000000..489a5f5
--- /dev/null
+++ b/core/modules/big_pipe/js/big_pipe.js
@@ -0,0 +1,90 @@
+/**
+ * @file
+ * Provides Ajax page updating via BigPipe.
+ */
+
+(function ($, window, Drupal, drupalSettings) {
+
+  "use strict";
+
+  var interval = 100; // Check every 100 ms.
+  var maxWait = 10; // Wait for a maximum of 10 seconds.
+
+  // The internal ID to contain the watcher service.
+  var intervalID;
+
+  function BigPipeClearInterval() {
+    if (intervalID) {
+      clearInterval(intervalID);
+      intervalID = undefined;
+    }
+  }
+
+  function BigPipeProcessPlaceholders(context) {
+    var $container = jQuery('[data-big-pipe-container=1]', context);
+
+    if (!$container.length) {
+      return;
+    }
+
+    // Process BigPipe inlined ajax responses.
+    $container.find('script[data-drupal-ajax-processor="big_pipe"]').each(function() {
+      var placeholder = $(this).data('big-pipe-placeholder');
+
+      // Ignore any placeholders that are not in the known placeholder list.
+      // This is used to avoid someone trying to XSS the site via the
+      // placeholdering mechanism.
+      if (typeof(drupalSettings.bigPipePlaceholders[placeholder]) !== 'undefined') {
+        var response = JSON.parse(this.textContent);
+        // Use a dummy url.
+        var ajaxObject = Drupal.ajax({url: 'big-pipe/placeholder.json'});
+        ajaxObject.success(response);
+      }
+      $(this).remove();
+    });
+
+    // Check for start signal to attachBehaviors.
+    $container.find('script[data-big-pipe-start="1"]').each(function() {
+      $(this).remove();
+      Drupal.attachBehaviors();
+    });
+
+    // Check for stop signal to stop checking.
+    $container.find('script[data-big-pipe-stop="1"]').each(function() {
+      $(this).remove();
+      BigPipeClearInterval();
+    });
+  }
+
+  $('body').each(function() {
+    if ($(this).data('big-pipe-processed') == true) {
+      return;
+    }
+
+    $(this).data('big-pipe-processed', true);
+
+    // Check for new BigPipe elements until we get the stop signal or the timeout occurs.
+    intervalID = setInterval(function() {
+      BigPipeProcessPlaceholders(document);
+    }, 100);
+
+    // Wait for a maxium of maxWait seconds.
+    setTimeout(BigPipeClearInterval, maxWait * 1000);
+  });
+
+  /**
+   * Defines the BigPipe behavior.
+   *
+   * @type {Drupal~behavior}
+   */
+  Drupal.behaviors.BigPipe = {
+    attach: function (context, settings) {
+      if (!intervalID) {
+        // If we timeout before all data is loaded, try again once
+        // the regular ready() event fires.
+        BigPipeProcessPlaceholders(context);
+      }
+    }
+  };
+
+})(jQuery, this, Drupal, drupalSettings);
diff --git a/core/modules/big_pipe/src/EventSubscriber/HtmlResponseBigPipeSubscriber.php b/core/modules/big_pipe/src/EventSubscriber/HtmlResponseBigPipeSubscriber.php
new file mode 100644
index 0000000..b45adb3
--- /dev/null
+++ b/core/modules/big_pipe/src/EventSubscriber/HtmlResponseBigPipeSubscriber.php
@@ -0,0 +1,130 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\big_pipe\EventSubscriber\HtmlResponseBigPipeSubscriber.
+ */
+
+namespace Drupal\big_pipe\EventSubscriber;
+
+use Drupal\Core\Render\HtmlResponse;
+use Drupal\big_pipe\Render\BigPipeInterface;
+use Drupal\big_pipe\Render\BigPipeResponse;
+use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
+use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+/**
+ * Response subscriber to replace the HtmlResponse with a BigPipeResponse.
+ */
+class HtmlResponseBigPipeSubscriber implements EventSubscriberInterface {
+
+  /**
+   * The BigPipe service.
+   *
+   * @var \Drupal\big_pipe\Render\BigPipeInterface
+   */
+  protected $bigPipe;
+
+  /**
+   * Constructs a HtmlResponseBigPipeSubscriber object.
+   *
+   * @param \Drupal\big_pipe\Render\BigPipeInterface $big_pipe
+   *   The BigPipe service.
+   */
+  public function __construct(BigPipeInterface $big_pipe) {
+    $this->bigPipe = $big_pipe;
+  }
+
+  /**
+   * Adds markers to the response necessary for the BigPipe render strategy.
+   *
+   * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
+   *   The event to process.
+   */
+  public function onRespondEarly(FilterResponseEvent $event) {
+    $response = $event->getResponse();
+    if (!$response instanceof HtmlResponse) {
+      return;
+    }
+
+    // Set a marker around 'scripts_bottom'
+    $attachments = $response->getAttachments();
+    if (isset($attachments['html_response_attachment_placeholders']['scripts_bottom'])) {
+      $scripts_bottom_placeholder = $attachments['html_response_attachment_placeholders']['scripts_bottom'];
+      $content = $response->getContent();
+
+      // Wrap the scripts_bottom placeholder with a marker before and after,
+      // because \Drupal\big_pipe\Render\BigPipe needs to be able to parse out
+      // that placeholder for the "HalfPipe" render strategy.
+      $content = str_replace($scripts_bottom_placeholder, '<drupal-big-pipe-scripts-bottom-marker>' . $scripts_bottom_placeholder . '<drupal-big-pipe-scripts-bottom-marker>', $content);
+      $response->setContent($content);
+    }
+  }
+
+  /**
+   * Transforms a HtmlResponse to a BigPipeResponse.
+   *
+   * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
+   *   The event to process.
+   */
+  public function onRespond(FilterResponseEvent $event) {
+    if (!$event->isMasterRequest()) {
+      return;
+    }
+
+    $response = $event->getResponse();
+    if (!$response instanceof HtmlResponse) {
+      return;
+    }
+
+    $attachments = $response->getAttachments();
+    if (empty($attachments['big_pipe_placeholders'])) {
+      // Remove our marker again.
+      $content = $response->getContent();
+      $content = str_replace('<drupal-big-pipe-scripts-bottom-marker>', '', $content);
+      $response->setContent($content);
+      return;
+    }
+
+    // Create a new Response.
+    $big_pipe_response = new BigPipeResponse();
+
+    // Clone the response.
+    $big_pipe_response->headers = clone $response->headers;
+    $big_pipe_response->setStatusCode($response->getStatusCode());
+    $big_pipe_response->setContent($response->getContent());
+    $big_pipe_response->addCacheableDependency($response->getCacheableMetadata());
+
+    // Add header to support streaming on NGINX + php-fpm (nginx >= 1.5.6).
+    $big_pipe_response->headers->set('X-Accel-Buffering', 'no');
+
+    // Inject the placeholders and service into the response.
+    $big_pipe_response->setBigPipePlaceholders($attachments['big_pipe_placeholders']);
+    $big_pipe_response->setBigPipeService($this->bigPipe);
+    unset($attachments['big_pipe_placeholders']);
+
+    // Set the remaining attachments.
+    $big_pipe_response->setAttachments($attachments);
+
+    // And set the new response.
+    $event->setResponse($big_pipe_response);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function getSubscribedEvents() {
+    // Run after HtmlResponsePlaceholderStrategySubscriber (priority 5), i.e.
+    // after BigPipeStrategy has been applied, but before normal (priority 0)
+    // response subscribers have been applied, because by then it'll be too late
+    // to transform it into a BigPipeResponse.
+    $events[KernelEvents::RESPONSE][] = ['onRespondEarly', 3];
+
+    // Run as the last possible subscriber.
+    $events[KernelEvents::RESPONSE][] = ['onRespond', -10000];
+
+    return $events;
+  }
+
+}
diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php
new file mode 100644
index 0000000..73e9d69
--- /dev/null
+++ b/core/modules/big_pipe/src/Render/BigPipe.php
@@ -0,0 +1,274 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\big_pipe\Render\BigPipe.
+ */
+
+namespace Drupal\big_pipe\Render;
+
+use Drupal\Core\Ajax\AjaxResponse;
+use Drupal\Core\Ajax\ReplaceCommand;
+use Drupal\Core\Asset\AttachedAssets;
+use Drupal\Core\Render\BubbleableMetadata;
+use Drupal\Core\Render\RendererInterface;
+use Drupal\Core\Render\AttachmentsResponseProcessorInterface;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\HttpKernel\Kernel;
+use Symfony\Component\HttpKernel\KernelEvents;
+
+/**
+ * A class that allows sending the main content first, then replace
+ * placeholders to send the rest using Javascript replacements.
+ */
+class BigPipe implements BigPipeInterface {
+
+  /**
+   * The renderer.
+   *
+   * @var \Drupal\Core\Render\RendererInterface
+   */
+  protected $renderer;
+
+  /**
+   * The AJAX response attachments processor service.
+   *
+   * @var \Drupal\Core\Render\AttachmentsResponseProcessorInterface
+   */
+  protected $ajaxResponseAttachmentsProcessor;
+
+  /**
+   * The HTML response attachments processor service.
+   *
+   * @var \Drupal\Core\Render\AttachmentsResponseProcessorInterface
+   */
+  protected $htmlResponseAttachmentsProcessor;
+
+  /**
+   * Constructs a new BigPipe class.
+   *
+   * @param \Drupal\Core\Render\RendererInterface
+   *   The renderer.
+   * @param \Drupal\Core\Render\AttachmentsResponseProcessorInterface $ajax_response_attachments_processor
+   *   The AJAX response attachments processor service.
+   * @param \Drupal\Core\Render\AttachmentsResponseProcessorInterface $html_response_attachments_processor
+   *   The HTML response attachments processor service.
+   */
+  public function __construct(RendererInterface $renderer, AttachmentsResponseProcessorInterface $ajax_response_attachments_processor, AttachmentsResponseProcessorInterface $html_response_attachments_processor) {
+    $this->renderer = $renderer;
+    $this->ajaxResponseAttachmentsProcessor = $ajax_response_attachments_processor;
+    $this->htmlResponseAttachmentsProcessor= $html_response_attachments_processor;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function sendContent($content, $attachments, array $placeholders) {
+    // We are sending a BigPipeResponse in this method. A BigPipeResponse is an
+    // aggregated response: it consists of a HtmlResponse plus multiple embedded
+    // AjaxResponses. The embedded AjaxResponses are generated here, in this
+    // method: one for each placeholder that needs to be replaced. This means
+    // that each AjaxResponse needs to be aware of the asset libraries that have
+    // already been loaded by the initial HtmlResponse plus all the preceding
+    // AjaxResponses. An AttachedAssetsInterface object is a perfect way to
+    // track this over time.
+    $assets = AttachedAssets::createFromRenderArray(['#attached' => $attachments]);
+    $assets->setAlreadyLoadedLibraries(explode(',', $attachments['drupalSettings']['ajaxPageState']['libraries']));
+
+    // Extract the scripts_bottom markup; the HalfPipe render strategy needs to
+    // be able to update it.
+    $t = explode('<drupal-big-pipe-scripts-bottom-marker>', $content, 3);
+    assert('count($t) == 3', 'There is content before and after scripts_bottom.');
+    $scripts_bottom = $t[1];
+    unset($t[1]);
+    $content = implode('', $t);
+
+    // Split it up in various chunks.
+    $page_parts = explode('</body>', $content);
+    if (count($page_parts) !== 2) {
+      throw new \LogicException("You need to have only one body or one <!-- X-RENDER-CACHE-BIG-PIPE-SPLIT --> tag in your html.html.twig template file.");
+    }
+
+    $half_pipe_placeholders = [];
+
+    if (empty($_SESSION['big_pipe_has_js'])) {
+      $half_pipe_placeholders = $placeholders;
+      $placeholders = [];
+    }
+
+    foreach ($placeholders as $key => $placeholder) {
+      if ($placeholder['#create_placeholder_options']['big_pipe']['renderer'] == 'half_pipe') {
+        $half_pipe_placeholders[$key] = $placeholder;
+        unset($placeholders[$key]);
+      }
+    }
+
+    if (!empty($half_pipe_placeholders)) {
+      $extra_attachments = $this->doHalfPipe($page_parts[0], $half_pipe_placeholders);
+      // Print the extra attachments.
+      if (!empty($extra_attachments['library']) || !empty($extra_attachments['drupalSettings'])) {
+        $all_attachments = BubbleableMetadata::mergeAttachments($attachments, $extra_attachments);
+
+        // Update the extra libraries using the Response's ajax page state.
+        // In the ideal case this will be empty and all libraries have been
+        // to the bottom js section already.
+        $variables_extra = $this->htmlResponseAttachmentsProcessor->processAssetLibraries($extra_attachments, [ 'scripts' => 'TRUE', 'styles' => TRUE ], $this->ajaxPageState);
+        if (!empty($variables_extra['styles'])) {
+          print $this->renderer->renderRoot($variables_extra['styles']);
+        }
+        if (!empty($variables_extra['styles'])) {
+          print $this->renderer->renderRoot($variables_extra['scripts']);
+        }
+
+        // Now that the placeholders have been rendered using the HalfPipe
+        // render strategy, recalculate the scripts_bottom markup.
+        $variables = $this->htmlResponseAttachmentsProcessor->processAssetLibraries($all_attachments, [ 'scripts_bottom' => TRUE ]);
+        $scripts_bottom = $this->renderer->renderRoot($variables['scripts_bottom']);
+      }
+    }
+    else {
+      print $page_parts[0];
+      ob_end_flush();
+    }
+
+    // Send the JavaScript at the bottom of the page.
+    print $scripts_bottom;
+
+    flush();
+
+    if (empty($placeholders)) {
+      print '</body>';
+      print $page_parts[1];
+      return;
+    }
+
+    // Print a container and the start signal.
+    print "\n";
+    print '  <div data-big-pipe-container="1">' . "\n";
+    print '    <script type="application/json" data-big-pipe-start="1"></script>' . "\n";
+
+    flush();
+
+    // Sort placeholders by the order in which they appear in the markup.
+    $order = $this->getPlaceholderOrder($content);
+
+    foreach ($order as $placeholder) {
+      if (!isset($placeholders[$placeholder])) {
+        continue;
+      }
+
+      // Check if the placeholder is present at all.
+      if (strpos($content, $placeholder) === FALSE) {
+        continue;
+      }
+
+      $placeholder_elements = $placeholders[$placeholder];
+
+      // Render the placeholder.
+      $elements = $this->renderPlaceholder($placeholder, $placeholder_elements);
+
+      // Create a new AjaxResponse.
+      $response = new AjaxResponse();
+      $response->addCommand(new ReplaceCommand(sprintf('[data-big-pipe-selector="%s"]', $placeholder), $elements['#markup']));
+      $response->setAttachments($elements['#attached']);
+
+      // @todo Clean up.
+      $request_stack = \Drupal::service('request_stack');
+      $master_request = $request_stack->getMasterRequest();
+      $request = Request::create($master_request->getUri(), $master_request->getMethod(), $master_request->query->all(), $master_request->cookies->all(), array(), $master_request->server->all());
+      $request->headers->set('Accept', 'application/json');
+      $request->request->set('ajax_page_state', ['libraries' => implode(',', $assets->getAlreadyLoadedLibraries())] + $assets->getSettings()['ajaxPageState']);
+      $request_stack->push($request);
+      $event = new FilterResponseEvent(\Drupal::service('http_kernel.basic'), $request, HttpKernelInterface::SUB_REQUEST, $response);
+      \Drupal::service('event_dispatcher')->dispatch(KernelEvents::RESPONSE, $event);
+      $response = $event->getResponse();
+      $request_stack->pop();
+
+      // @todo Filter response.
+      $json = $response->getContent();
+
+      $output = <<<EOF
+    <script type="application/json" data-big-pipe-placeholder="$placeholder" data-drupal-ajax-processor="big_pipe">
+    $json
+    </script>
+
+EOF;
+      print $output;
+
+      flush();
+
+      // Another placeholder was rendered and sent, track the set of asset
+      // libraries sent so far.
+      $assets->setAlreadyLoadedLibraries(explode(',', $response->getAttachments()['drupalSettings']['ajaxPageState']['libraries']));
+    }
+
+    // Send the stop signal.
+    print '    <script type="application/json" data-big-pipe-stop="1"></script>' . "\n";
+    print '  </div>' . "\n";
+    print '</body>';
+    print $page_parts[1];
+
+    return $this;
+  }
+
+  protected function renderPlaceholder($placeholder, $placeholder_elements) {
+    // Create elements to process in right format.
+    $elements = [
+      '#markup' => $placeholder,
+      '#attached' => [
+        'placeholders' => [
+          $placeholder => $placeholder_elements,
+        ],
+      ],
+    ];
+
+    return $this->renderer->renderPlaceholder($placeholder, $elements);
+  }
+
+  protected function getPlaceholderOrder($content, $selector = '<div data-big-pipe-selector="') {
+    $fragments = explode($selector, $content);
+    array_shift($fragments);
+    $order = [];
+
+    foreach ($fragments as $fragment) {
+      $t = explode('"></div>', $fragment, 2);
+      $placeholder = $t[0];
+      $order[] = $placeholder;
+    }
+
+    return $order;
+  }
+
+  protected function doHalfPipe($content, $placeholders, $selector = '<div data-big-pipe-selector="') {
+    $fragments = explode($selector, $content);
+    print array_shift($fragments);
+    ob_end_flush();
+    flush();
+
+    $attachments = array();
+
+    foreach ($fragments as $fragment) {
+      $t = explode('"></div>', $fragment, 2);
+      $placeholder = $t[0];
+      if (!isset($placeholders[$placeholder])) {
+        continue;
+      }
+
+      // Render the placeholder.
+      $elements = $this->renderPlaceholder($placeholder, $placeholders[$placeholder]);
+      if (!empty($elements['#attached'])) {
+        $attachments = BubbleableMetadata::mergeAttachments($attachments, $elements['#attached']);
+      }
+
+      print $elements['#markup'];
+      print $t[1];
+      flush();
+    }
+
+    return $attachments;
+  }
+
+}
diff --git a/core/modules/big_pipe/src/Render/BigPipeInterface.php b/core/modules/big_pipe/src/Render/BigPipeInterface.php
new file mode 100644
index 0000000..0adcd17
--- /dev/null
+++ b/core/modules/big_pipe/src/Render/BigPipeInterface.php
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\big_pipe\Render\BigPipeInterface.
+ */
+
+namespace Drupal\big_pipe\Render;
+
+/**
+ * An interface that allows sending the main content first, then replace
+ * placeholders to send the rest using Javascript replacements.
+ */
+interface BigPipeInterface {
+
+  /**
+   * Sends the content to the browser, splitting before the closing </body> tag
+   * and afterwards processes placeholders to send when they have been rendered.
+   *
+   * The output buffers are flushed in between.
+   *
+   * @param array $placeholders
+   *   The placeholders to process.
+   * @param string $content
+   *   The content to send.
+   */
+  public function sendContent($content, $attachments, array $placeholders);
+
+}
diff --git a/core/modules/big_pipe/src/Render/BigPipeResponse.php b/core/modules/big_pipe/src/Render/BigPipeResponse.php
new file mode 100644
index 0000000..bb09370
--- /dev/null
+++ b/core/modules/big_pipe/src/Render/BigPipeResponse.php
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\big_pipe\Render\BigPipeResponse.
+ */
+
+namespace Drupal\big_pipe\Render;
+
+use Drupal\Core\Render\HtmlResponse;
+
+/**
+ * A response that allows to send placeholders after the main content has been
+ * send.
+ */
+class BigPipeResponse extends HtmlResponse {
+
+  /**
+   * An array of placeholders to process.
+   *
+   * @var array
+   */
+  protected $bigPipePlaceholders;
+
+  /**
+   * The BigPipe service.
+   *
+   * @var \Drupal\big_pipe\Render\BigPipeInterface
+   */
+  protected $bigPipe;
+
+  /**
+   * Sets the big pipe placeholders to process.
+   *
+   * @param array $placeholders
+   *   The placeholders to process.
+   */
+  public function setBigPipePlaceholders(array $placeholders) {
+    $this->bigPipePlaceholders = $placeholders;
+  }
+
+  /**
+   * Sets the big pipe service to use.
+   *
+   * @param \Drupal\big_pipe\Render\BigPipeInterface $big_pipe
+   *   The BigPipe service.
+   */
+  public function setBigPipeService(BigPipeInterface $big_pipe) {
+    $this->bigPipe = $big_pipe;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function sendContent() {
+    $this->bigPipe->sendContent($this->content, $this->getAttachments(), $this->bigPipePlaceholders);
+
+    return $this;
+  }
+}
diff --git a/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php
new file mode 100644
index 0000000..4a01140
--- /dev/null
+++ b/core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php
@@ -0,0 +1,107 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\big_pipe\Render\Placeholder\BigPipeStrategy
+ */
+
+namespace Drupal\big_pipe\Render\Placeholder;
+
+use Drupal\Component\Utility\Crypt;
+use Drupal\Component\Utility\Html;
+use Drupal\Core\Render\Placeholder\PlaceholderStrategyInterface;
+use Drupal\Core\Session\AccountInterface;
+
+/**
+ * Defines the 'big_pipe' render strategy.
+ *
+ * This is the last strategy that always replaces all remaining placeholders.
+ */
+class BigPipeStrategy implements PlaceholderStrategyInterface {
+
+  /**
+   * The current user.
+   *
+   * @var \Drupal\Core\Session\AccountInterface
+   */
+  protected $currentUser;
+
+  /**
+   * Constructs a new BigPipeStrategy class.
+   *
+   * @param \Drupal\Core\Session\AccountInterface $current_user
+   *   The current user.
+   */
+  public function __construct(AccountInterface $current_user) {
+    $this->currentUser = $current_user;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function processPlaceholders(array $placeholders) {
+    $return = [];
+
+    // @todo Move to a ResponsePolicy instead.
+    // @todo Add user.roles:authenticated cache context.
+    if (!$this->currentUser->isAuthenticated()) {
+      return $return;
+    }
+
+    // @todo Add 'session' cache context.
+    if (empty($_SESSION['big_pipe_has_js'])) {
+      return $return;
+    }
+
+    // Ensure placeholders are unique per page.
+    $token = '';
+
+    foreach ($placeholders as $placeholder => $placeholder_elements) {
+      // Blacklist some #lazy_builder callbacks.
+      // @todo Use #create_placeholder_options instead.
+      if (isset($placeholder_elements['#lazy_builder'][0])) {
+        // Route CSRF tokens, form CSRF token and form actions are (part of)
+        // HTML attributes, not HTML.
+        if ($placeholder_elements['#lazy_builder'][0] == 'route_processor_csrf:renderPlaceholderCsrfToken') {
+          continue;
+        }
+        elseif ($placeholder_elements['#lazy_builder'][0] == 'form_builder:renderPlaceholderFormAction') {
+          continue;
+        }
+        elseif ($placeholder_elements['#lazy_builder'][0] == 'form_builder:renderFormTokenPlaceholder') {
+          continue;
+        }
+      }
+
+      $placeholder_elements += [ '#create_placeholder_options' => []];
+      $placeholder_elements['#create_placeholder_options'] += [ 'big_pipe' => []];
+      $placeholder_elements['#create_placeholder_options']['big_pipe'] += [
+        'renderer' => 'big_pipe',
+      ];
+
+      $html_placeholder = Html::getId($placeholder . '-' . $token);
+      $return[$placeholder] = [
+         '#markup' => '<div data-big-pipe-selector="' . $html_placeholder . '"></div>',
+         // Big Pipe placeholders are not cacheable.
+         '#cache' => [
+           'max-age' => 0,
+         ],
+         '#attached' => [
+           // Use the big_pipe library.
+           'library' => [
+             'big_pipe/big_pipe',
+           ],
+           // Add the placeholder to a white list of JS processed placeholders.
+           'drupalSettings' => [
+             'bigPipePlaceholders' => [ $html_placeholder => TRUE ],
+           ],
+           'big_pipe_placeholders' => [
+             $html_placeholder => $placeholder_elements,
+           ],
+         ],
+      ];
+    }
+
+    return $return;
+  }
+}
diff --git a/core/modules/system/src/Tests/Common/AttachedAssetsTest.php b/core/modules/system/src/Tests/Common/AttachedAssetsTest.php
index 7440d99..cc04606 100644
--- a/core/modules/system/src/Tests/Common/AttachedAssetsTest.php
+++ b/core/modules/system/src/Tests/Common/AttachedAssetsTest.php
@@ -108,8 +108,10 @@ function testAddJsSettings() {
     $build['#attached']['library'][] = 'core/drupalSettings';
     $assets = AttachedAssets::createFromRenderArray($build);
 
+    $this->assertEqual([], $assets->getSettings(), 'JavaScript settings on $assets are empty.');
     $javascript = $this->assetResolver->getJsAssets($assets, FALSE)[1];
     $this->assertTrue(array_key_exists('currentPath', $javascript['drupalSettings']['data']['path']), 'The current path JavaScript setting is set correctly.');
+    $this->assertTrue(array_key_exists('currentPath', $assets->getSettings()['path']), 'JavaScript settings on $assets are resolved after retrieving JavaScript assets, and are equal to the returned JavaScript settings.');
 
     $assets->setSettings(['drupal' => 'rocks', 'dries' => 280342800]);
     $javascript = $this->assetResolver->getJsAssets($assets, FALSE)[1];
