diff --git a/field_example/field_example.libraries.yml b/field_example/field_example.libraries.yml
new file mode 100644
index 0000000..f6bb909
--- /dev/null
+++ b/field_example/field_example.libraries.yml
@@ -0,0 +1,6 @@
+field_example:
+  version: 1.x
+  js:
+    field_example.js: {}
+  dependencies:
+    - core/jquery.farbtastic
diff --git a/field_example/src/Plugin/Field/FieldWidget/ColorPickerWidget.php b/field_example/src/Plugin/Field/FieldWidget/ColorPickerWidget.php
index 0f14a12..b3b5925 100644
--- a/field_example/src/Plugin/Field/FieldWidget/ColorPickerWidget.php
+++ b/field_example/src/Plugin/Field/FieldWidget/ColorPickerWidget.php
@@ -33,12 +33,10 @@ class ColorPickerWidget extends TextWidget {
       '#suffix' => '<div class="field-example-colorpicker"></div>',
       '#attributes' => array('class' => array('edit-field-example-colorpicker')),
       '#attached' => array(
-        // Add Farbtastic color picker.
+        // Add Farbtastic color picker via the field_example library
         'library' => array(
-          'core/jquery.farbtastic',
+          'field_example/field_example',
         ),
-        // Add javascript to trigger the colorpicker.
-        'js' => array(drupal_get_path('module', 'field_example') . '/field_example.js'),
       ),
     );
 
