diff --git a/core/modules/history/history.module b/core/modules/history/history.module
index 4a2b2e3e4c5f74480c3d99723d6b73f4edcd6989..06e82d89e03fc22469cabcae0e0b1239e57d6fcd 100644
--- a/core/modules/history/history.module
+++ b/core/modules/history/history.module
@@ -135,20 +135,14 @@ function history_cron() {
 function history_node_view_alter(array &$build, EntityInterface $node, EntityViewDisplayInterface $display) {
   // Update the history table, stating that this user viewed this node.
   if (($display->originalMode === 'full') && \Drupal::currentUser()->isAuthenticated()) {
-    $build['#attached'] = array(
-      'js' => array(
-        // When the window's "load" event is triggered, mark the node as read.
-        // This still allows for Drupal behaviors (which are triggered on the
-        // "DOMContentReady" event) to add "new" and "updated" indicators.
-        array(
-          'data' => 'window.addEventListener("load",function(){Drupal.history.markAsRead(' . $node->id() . ');},false);',
-          'type' => 'inline',
-        ),
-      ),
-      'library' => array(
-        'history/drupal.history',
-      ),
+    // When the window's "load" event is triggered, mark the node as read.
+    // This still allows for Drupal behaviors (which are triggered on the
+    // "DOMContentReady" event) to add "new" and "updated" indicators.
+    $build['#attached']['js'][] = array(
+      'data' => 'window.addEventListener("load",function(){Drupal.history.markAsRead(' . $node->id() . ');},false);',
+      'type' => 'inline',
     );
+    $build['#attached']['library'][] = 'history/drupal.history';
   }
 
 }