How do I get a list of all CSS and JS that are attached to a page? In Drupal 8, how do I get all CSS and JS that is attached to a page? In Drupal 7, I could use drupal_add_css() or drupal_add_js() without arguments, to get an array containing a list of all the files/inline added to a page.

I'm developing a module that will display a "preview" of the block on block configuration page. The method I chose is displaying the block code in a &lt;iframe&gt;, but to be properly styled, I need to output all styles with it. This is why I want to read all possible CSS/JS in this "preview" page controller.
You cannot get a list of css/js files because it is constructed very late in the render process.

However, since you want to use an iframe to achieve that goal, you can get it through the normal loading order of a drupal page.

The following is a proof of concept controller method you can use to display a block in a simplified html mode.

public function preview($block_id) {
  /** @var BlockInterface $block */
  $block = Block::load($block_id);

  /** @var BareHtmlPageRendererInterface $bare_html_page_renderer */
  $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
  $content = [
    'preview-child' =&gt; \Drupal::entityTypeManager()-&gt;getViewBuilder('block')-&gt;view($block)
  ];

  return $bare_html_page_renderer-&gt;renderBarePage($content, 'preview-title', 'preview-theme');
}