diff --git a/core/modules/views/includes/ajax.inc b/core/modules/views/includes/ajax.inc
index 9d5f0ce..09ef4f5 100644
--- a/core/modules/views/includes/ajax.inc
+++ b/core/modules/views/includes/ajax.inc
@@ -6,6 +6,9 @@
  */
 
 use Symfony\Component\HttpFoundation\JsonResponse;
+use Drupal\Core\Ajax\AjaxResponse;
+use Drupal\Core\Ajax\ReplaceCommand;
+use Drupal\views\Ajax\ScrollTopCommand;
 
 /**
  * @defgroup ajax Views AJAX library
@@ -29,7 +32,7 @@ function views_ajax() {
     $pager_element = $request->request->get('pager_element');
     $pager_element = isset($pager_element) ? intval($pager_element) : NULL;
 
-    $commands = array();
+    $response = new AjaxResponse();
 
     // Remove all of this stuff from the query of the request so it doesn't end
     // up in pagers and tablesort URLs.
@@ -68,16 +71,15 @@ function views_ajax() {
 
       // Override the display's pager_element with the one actually used.
       if (isset($pager_element)) {
-        $commands[] = views_ajax_command_scroll_top('.view-dom-id-' . $dom_id);
+        $response->addCommand(new ScrollTopCommand(".view-dom-id-$dom_id"));
         $view->displayHandlers[$display_id]->setOption('pager_element', $pager_element);
       }
       // Reuse the same DOM id so it matches that in Drupal.settings.
       $view->dom_id = $dom_id;
 
-      $commands[] = ajax_command_replace('.view-dom-id-' . $dom_id, $view->preview($display_id, $args));
+      $response->addCommand(new ReplaceCommand(".view-dom-id-$dom_id", $view->preview($display_id, $args)));
     }
-    drupal_alter('views_ajax_data', $commands, $view);
-    return array('#type' => 'ajax', '#commands' => $commands);
+    return $response;
   }
 }
 
@@ -159,20 +161,6 @@ function views_ajax_command_add_tab($id, $title, $body) {
 }
 
 /**
- * Scroll to top of the current view.
- *
- * @return
- *   An array suitable for use with the ajax_render() function.
- */
-function views_ajax_command_scroll_top($selector) {
-  $command = array(
-    'command' => 'viewsScrollTop',
-    'selector' => $selector,
-  );
-  return $command;
-}
-
-/**
  * Shows Save and Cancel buttons.
  *
  * @return
diff --git a/core/modules/views/lib/Drupal/views/Ajax/ScrollTopCommand.php b/core/modules/views/lib/Drupal/views/Ajax/ScrollTopCommand.php
new file mode 100644
index 0000000..6b9eb21
--- /dev/null
+++ b/core/modules/views/lib/Drupal/views/Ajax/ScrollTopCommand.php
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\views\Ajax\ScrollTopCommand.
+ */
+
+namespace Drupal\views\Ajax;
+
+use Drupal\Core\Ajax\CommandInterface;
+
+/**
+ * Provides an AJAX command for scolling to the top of an element.
+ *
+ * This command is implemented in Drupal.ajax.prototype.commands.viewsScrollTop.
+ */
+class ScrollTopCommand implements CommandInterface {
+
+  /**
+   * A CSS selector string.
+   *
+   * @var string
+   */
+  protected $selector;
+
+  /**
+   * Constructs a \Drupal\views\Ajax\ScrollTopCommand object.
+   *
+   * @param string $selector
+   *   A CSS selector.
+   */
+  public function __construct($selector) {
+    $this->selector = $selector;
+  }
+
+  /**
+   * Implements \Drupal\Core\Ajax\CommandInterface::render().
+   */
+  public function render() {
+    return array(
+      'command' => 'viewsScrollTop',
+      'selector' => $this->selector,
+    );
+  }
+
+}
diff --git a/core/modules/views/views_ui/views_ui.module b/core/modules/views/views_ui/views_ui.module
index b7040ac..45e55a3 100644
--- a/core/modules/views/views_ui/views_ui.module
+++ b/core/modules/views/views_ui/views_ui.module
@@ -10,7 +10,8 @@
 use Drupal\views_ui\ViewUI;
 use Drupal\views\Analyzer;
 use Drupal\Core\Entity\EntityInterface;
-use Symfony\Component\HttpFoundation\JsonResponse;
+use Drupal\Core\Ajax\AjaxResponse;
+use Drupal\Core\Ajax\ReplaceCommand;
 
 /**
  * Implements hook_menu().
@@ -768,8 +769,9 @@ function views_ui_ajax_callback(ViewExecutable $view, $op) {
   // If the request is via AJAX, return the rendered list as JSON.
   if (drupal_container()->get('request')->request->get('js')) {
     $list = entity_list_controller('view')->render();
-    $commands = array(ajax_command_replace('#views-entity-list', drupal_render($list)));
-    return new JsonResponse(ajax_render($commands));
+    $response = new AjaxResponse();
+    $response->addCommand(new ReplaceCommand('#views-entity-list', drupal_render($list)));
+    return $response;
   }
   // Otherwise, redirect back to the page.
   else {
