diff --git a/lib/Drupal/nodejs/EventSubscriber/NodejsSubscriber.php b/lib/Drupal/nodejs/EventSubscriber/NodejsSubscriber.php
index 5608aaa..ad28348 100644
--- a/lib/Drupal/nodejs/EventSubscriber/NodejsSubscriber.php
+++ b/lib/Drupal/nodejs/EventSubscriber/NodejsSubscriber.php
@@ -17,7 +17,8 @@ class NodejsSubscriber implements EventSubscriberInterface {
   public function initLibraries(GetResponseEvent $event) {
     drupal_register_shutdown_function(array('Nodejs', 'sendMessages'));
     if (nodejs_add_js_to_page_check()) {
-      drupal_add_library('nodejs', 'init');
+      $attached['#attached']['library'][] = 'nodejs/init';
+      drupal_render($attached);
     }
     
   }
diff --git a/nodejs.libraries.yml b/nodejs.libraries.yml
new file mode 100644
index 0000000..6d1a1d4
--- /dev/null
+++ b/nodejs.libraries.yml
@@ -0,0 +1,7 @@
+init:
+  version: 1.1
+  js:
+    nodejs.js: {}
+  dependencies:
+    - core/jquery
+    - core/drupal
diff --git a/nodejs.module b/nodejs.module
index cc6c2d1..bb498cb 100644
--- a/nodejs.module
+++ b/nodejs.module
@@ -303,41 +303,29 @@ function nodejs_menu_link_defaults() {
 }
 
 /**
- * Implements hook_library_info().
- */
-function nodejs_library_info() {
-  $_SESSION['nodejs_config'] = $nodejs_config = nodejs_get_config();
-  if (isset($nodejs_config['serviceKey'])) {
-    unset($nodejs_config['serviceKey']);
-  }
-  $socket_io_config = nodejs_get_socketio_js_config($nodejs_config);
-
-  $libraries['init'] = array(
-    'title' => 'Init nodejs',
-    'website' => 'https://drupal.org/project/nodejs',
-    'version' => '1.1',
-    'js' => array(
-      $socket_io_config['path'] => array(
-        'type' => $socket_io_config['type'],
-      ),
-      drupal_get_path('module', 'nodejs') . '/nodejs.js' => array(
-        'type' => 'file',
-      ),
-      array(
-        'type' => 'setting',
-        'data' => array('nodejs' => $nodejs_config),
-      ),
-    ),
-    'dependencies' => array(
-      array('system', 'jquery'),
-      array('system', 'drupal'),
-    ),
-  );
-  
-  foreach (nodejs_get_js_handlers() as $handler_file) {
-    $libraries['init']['js'][$handler_file] = array('type' => 'file');
+* Implements hook_library_alter().
+*/
+function nodejs_library_alter(array &$library, $name) {
+  if ($name == 'nodejs/init') {
+    $_SESSION['nodejs_config'] = $nodejs_config = nodejs_get_config();
+    if (isset($nodejs_config['serviceKey'])) {
+      unset($nodejs_config['serviceKey']);
+    }
+    $socket_io_config = nodejs_get_socketio_js_config($nodejs_config);
+
+    $library['js'][] = array(
+      'type' => $socket_io_config['type'],
+      'data' => $socket_io_config['path']
+    );
+    $library['js'][] = array(
+      'type' => 'setting',
+      'data' => array('nodejs' => $nodejs_config),
+    );
+
+    foreach (nodejs_get_js_handlers() as $handler_file) {
+      $library['js'][$handler_file] = array('type' => 'file');
+    }
   }
-  return $libraries;
 }
 
 /**
diff --git a/nodejs_ajax/lib/Drupal/nodejs_ajax/EventSubscriber/NodejsAjaxSubscriber.php b/nodejs_ajax/lib/Drupal/nodejs_ajax/EventSubscriber/NodejsAjaxSubscriber.php
index 8993d26..8a0a007 100644
--- a/nodejs_ajax/lib/Drupal/nodejs_ajax/EventSubscriber/NodejsAjaxSubscriber.php
+++ b/nodejs_ajax/lib/Drupal/nodejs_ajax/EventSubscriber/NodejsAjaxSubscriber.php
@@ -15,7 +15,8 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 class NodejsAjaxSubscriber implements EventSubscriberInterface {
 
   public function initLibraries(GetResponseEvent $event) {
-    drupal_add_library('system', 'drupal.ajax');
+    $attached['#attached']['library'][] = 'core/drupal.ajax';
+    drupal_render($attached);
   }
 
   /**
