diff --git a/hint.module b/hint.module
index 2843169..1de6316 100644
--- a/hint.module
+++ b/hint.module
@@ -25,10 +25,17 @@ function hint_menu() {
 }
 
 /**
- * Implementation of hook_init().
+ * Implements hook_library().
  */
-function hint_init() {
-  drupal_add_js(drupal_get_path('module', 'hint') . '/hint.js');
+function hint_library() {
+  $libraries['hint'] = array(
+    'name' => 'Hint',
+    'version' => '1.0',
+    'js' => array(
+      drupal_get_path('module', 'hint') . '/hint.js' => array(),
+    ),
+  );
+  return $libraries;
 }
 
 /**
@@ -46,12 +53,13 @@ function hint_element_info() {
 /**
  * Pre-render function to read #hint properties.
  */
-function hint_pre_render($element) {
+function hint_pre_render(&$element) {
 
   if (isset($element['#hint'])) {
     $class = 'hint-enabled';
     $element['#attributes']['title'] = $element['#hint'];
     $element['#attributes']['class'][] = $class;
+    $element['#attached']['library'][] = array('hint', 'hint');
   }
   if (isset($element['#hint_remove_title']) && $element['#hint_remove_title']) {
     unset($element['#title']);
