diff --git a/behat_javascript.module b/behat_javascript.module
index cdb84be..56b7007 100644
--- a/behat_javascript.module
+++ b/behat_javascript.module
@@ -4,35 +4,22 @@
  * @file
  * Primary module hooks for Behat javascript module.
  */
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\behat_javascript\Hook\BehatJavascriptHooks;
 use Drupal\Core\Routing\RouteMatchInterface;
 
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function behat_javascript_help($route_name, RouteMatchInterface $route_match) {
-  switch ($route_name) {
-    // Main module help for the behat_javascript module.
-    case 'help.page.behat_javascript':
-      $output = '';
-      $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('This module aims to provide tools to work with Behat tests and Javascript in Drupal projects.') . '</p>';
-      $output .= '<p>' . t('Features included:') . '</p>';
-      $output .= '<p>' . t('- Shows JS errors on Behat scenarios and marks them as failed.') . '</p>';
-      $output .= '<p>' . t('No configuration is needed, just enabling the module.') . '</p>';
-      $output .= '<p>' . t('Please note that this module must not be installed in production environments as it is only needed for testing purposes.') . '</p>';
-      $output .= '<p>' . t('This project is a drupal module adaptation of this library: <a href="https://github.com/25th-floor/behat-js-errorlog">https://github.com/25th-floor/behat-js-errorlog</a>') . '</p>';
-      $output .= '<h3>' . t('Supporting organizations:') . '</h3>';
-      $output .= '<p>' . t('<a href="https://www.drupal.org/metadrop">Metadrop Module development</a>') . '</p>';
-	  return $output;
-
-    default:
-  }
+  return \Drupal::service(BehatJavascriptHooks::class)->help($route_name, $route_match);
 }
 
 /**
  * Implements hook_page_attachments().
  */
+#[LegacyHook]
 function behat_javascript_page_attachments(array &$attachments) {
-  // Unconditionally attach an asset to the page.
-  $attachments['#attached']['library'][] = 'behat_javascript/errors';
+  \Drupal::service(BehatJavascriptHooks::class)->pageAttachments($attachments);
 }
diff --git a/behat_javascript.services.yml b/behat_javascript.services.yml
new file mode 100644
index 0000000..7d6286c
--- /dev/null
+++ b/behat_javascript.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\behat_javascript\Hook\BehatJavascriptHooks:
+    class: Drupal\behat_javascript\Hook\BehatJavascriptHooks
+    autowire: true
diff --git a/src/Hook/BehatJavascriptHooks.php b/src/Hook/BehatJavascriptHooks.php
new file mode 100644
index 0000000..290c689
--- /dev/null
+++ b/src/Hook/BehatJavascriptHooks.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Drupal\behat_javascript\Hook;
+
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+/**
+ * Hook implementations for behat_javascript.
+ */
+class BehatJavascriptHooks
+{
+    use StringTranslationTrait;
+    /**
+     * Implements hook_help().
+     */
+    #[Hook('help')]
+    public function help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match)
+    {
+        switch ($route_name) {
+            // Main module help for the behat_javascript module.
+            case 'help.page.behat_javascript':
+                $output = '';
+                $output .= '<h3>' . $this->t('About') . '</h3>';
+                $output .= '<p>' . $this->t('This module aims to provide tools to work with Behat tests and Javascript in Drupal projects.') . '</p>';
+                $output .= '<p>' . $this->t('Features included:') . '</p>';
+                $output .= '<p>' . $this->t('- Shows JS errors on Behat scenarios and marks them as failed.') . '</p>';
+                $output .= '<p>' . $this->t('No configuration is needed, just enabling the module.') . '</p>';
+                $output .= '<p>' . $this->t('Please note that this module must not be installed in production environments as it is only needed for testing purposes.') . '</p>';
+                $output .= '<p>' . $this->t('This project is a drupal module adaptation of this library: <a href="https://github.com/25th-floor/behat-js-errorlog">https://github.com/25th-floor/behat-js-errorlog</a>') . '</p>';
+                $output .= '<h3>' . $this->t('Supporting organizations:') . '</h3>';
+                $output .= '<p>' . $this->t('<a href="https://www.drupal.org/metadrop">Metadrop Module development</a>') . '</p>';
+                return $output;
+            default:
+        }
+    }
+    /**
+     * Implements hook_page_attachments().
+     */
+    #[Hook('page_attachments')]
+    public static function pageAttachments(array &$attachments)
+    {
+        // Unconditionally attach an asset to the page.
+        $attachments['#attached']['library'][] = 'behat_javascript/errors';
+    }
+}
