Attach javascript library and settings to a node page
try hook_entity_view or hook_node_view_alter:

/**
 * Implements hook_entity_view().
 */
function mymodule_entity_view(array &amp;$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {

  if ($entity-&gt;bundle() == 'background_carousel_page' &amp;&amp; $view_mode == 'full') {
    $build['#attached']['library'][] = 'mymodule/mylibrary';
  }

}


or

/**
 * Implements hook_ENTITY_TYPE_view_alter().
 */
function mymodule_node_view_alter(array &amp;$build) {
  // @see \Drupal\Tests\embed\Functional\EmbedPreviewTest::testPreview
  $build['#attached']['library'][] = 'mymodule/mylibrary';
}