diff --git a/plugins/facetapi/adapter.inc b/plugins/facetapi/adapter.inc
index 58b4cfc..0ace511 100644
--- a/plugins/facetapi/adapter.inc
+++ b/plugins/facetapi/adapter.inc
@@ -1055,7 +1055,6 @@ abstract class FacetapiAdapter {
     $this->processFacets();
 
     // Add JavaScript, initializes the realm specific render array.
-    drupal_add_js(drupal_get_path('module', 'facetapi') . '/facetapi.js');
     $build = array(
       '#adapter' => $this,
       '#realm' => $realm,
diff --git a/plugins/facetapi/widget.inc b/plugins/facetapi/widget.inc
index c84b2fa..e18c3db 100644
--- a/plugins/facetapi/widget.inc
+++ b/plugins/facetapi/widget.inc
@@ -143,6 +143,9 @@ abstract class FacetapiWidget {
         ),
         'id' => drupal_html_id("facetapi-facet-$searcher-{$this->realm['name']}-{$this->facet['name']}"),
       ),
+      '#attached' => array(
+        'js' => array(drupal_get_path('module', 'facetapi') . '/facetapi.js'),
+      ),
     );
 
     // Apply sorting algorithms to the render array.
