diff --git a/highlight.info.yml b/highlight.info.yml
index 1339acf..4ba4394 100644
--- a/highlight.info.yml
+++ b/highlight.info.yml
@@ -1,7 +1,7 @@
 name: Highlight
 description: Highlight key words from search results.
 package: Search
-core_version_requirement: ^9 || ^10 || ^11
+core_version_requirement: ^10.1 || ^11 || ^12
 
 type: module
 
diff --git a/highlight.module b/highlight.module
index bb43300..4b4ad4c 100644
--- a/highlight.module
+++ b/highlight.module
@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * @file
+ */
+
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\highlight\Hook\HighlightHooks;
+
 /**
  * @file
  * Hooks for the Highlight module.
@@ -8,18 +15,7 @@
 /**
  * Implements hook_page_attachments().
  */
+#[LegacyHook]
 function highlight_page_attachments(array &$attachments) {
-  $config = \Drupal::config('highlight.settings');
-
-  $attachments['#attached']['library'][] = 'highlight/highlight';
-  $attachments['#attached']['drupalSettings']['highlight'] = [
-    'area' => $config->get('area'),
-    'class' => $config->get('class'),
-    'color' => $config->get('color'),
-    'textColor' => $config->get('text_color'),
-    'wordsonly' => $config->get('wordsonly'),
-    'patterns' => implode("\n", $config->get('patterns')),
-    'referrerPatterns' => implode("\n", $config->get('patterns_referrer')),
-    'stopwords' => $config->get('stopwords'),
-  ];
+  \Drupal::service(HighlightHooks::class)->pageAttachments($attachments);
 }
diff --git a/highlight.services.yml b/highlight.services.yml
new file mode 100644
index 0000000..f201a17
--- /dev/null
+++ b/highlight.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\highlight\Hook\HighlightHooks:
+    class: Drupal\highlight\Hook\HighlightHooks
+    autowire: true
diff --git a/src/Hook/HighlightHooks.php b/src/Hook/HighlightHooks.php
new file mode 100644
index 0000000..df87bcf
--- /dev/null
+++ b/src/Hook/HighlightHooks.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\highlight\Hook;
+
+use Drupal\Core\Hook\Attribute\Hook;
+
+/**
+ * Hook implementations for highlight.
+ */
+class HighlightHooks {
+  /**
+   * @file
+   * Hooks for the Highlight module.
+   */
+
+  /**
+   * Implements hook_page_attachments().
+   */
+  #[Hook('page_attachments')]
+  public static function pageAttachments(array &$attachments) {
+    $config = \Drupal::config('highlight.settings');
+    $attachments['#attached']['library'][] = 'highlight/highlight';
+    $attachments['#attached']['drupalSettings']['highlight'] = [
+      'area' => $config->get('area'),
+      'class' => $config->get('class'),
+      'color' => $config->get('color'),
+      'textColor' => $config->get('text_color'),
+      'wordsonly' => $config->get('wordsonly'),
+      'patterns' => implode("\n", $config->get('patterns')),
+      'referrerPatterns' => implode("\n", $config->get('patterns_referrer')),
+      'stopwords' => $config->get('stopwords'),
+    ];
+  }
+
+}
diff --git a/tests/src/Functional/HighlightEnabledTest.php b/tests/src/Functional/HighlightEnabledTest.php
index c951152..9678c1d 100644
--- a/tests/src/Functional/HighlightEnabledTest.php
+++ b/tests/src/Functional/HighlightEnabledTest.php
@@ -2,11 +2,13 @@
 
 namespace Drupal\Tests\highlight\Functional;
 
+use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
 use Drupal\Tests\BrowserTestBase;
 
 /**
  * Tests that the highlight.js file is properly attached to pages.
  */
+#[RunTestsInSeparateProcesses]
 class HighlightEnabledTest extends BrowserTestBase {
 
   /**
