diff --git a/core/includes/common.inc b/core/includes/common.inc
index 08ce2ab..f3c4d58 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -4098,7 +4098,7 @@ function drupal_add_js($data = NULL, $options = NULL) {
   if (isset($data)) {
     // Add jquery.js and drupal.js, as well as the basePath setting, the
     // first time a JavaScript file is added.
-    if (empty($javascript)) {
+    if (empty($javascript['settings'])) {
       // url() generates the prefix using hook_url_outbound_alter(). Instead of
       // running the hook_url_outbound_alter() again here, extract the prefix
       // from url().
@@ -4116,18 +4116,21 @@ function drupal_add_js($data = NULL, $options = NULL) {
           'weight' => 0,
           'browsers' => array(),
         ),
-        'core/misc/drupal.js' => array(
-          'data' => 'core/misc/drupal.js',
-          'type' => 'file',
-          'scope' => 'header',
-          'group' => JS_LIBRARY,
-          'every_page' => TRUE,
-          'weight' => -1,
-          'preprocess' => TRUE,
-          'cache' => TRUE,
-          'defer' => FALSE,
-          'browsers' => array(),
-        ),
+      );
+    }
+    // If any js is added other than a setting, add default js files.
+    if ($options['type'] != 'setting' && !array_diff_key($javascript, array('settings' => TRUE))) {
+      $javascript['core/misc/drupal.js'] = array(
+        'data' => 'core/misc/drupal.js',
+        'type' => 'file',
+        'scope' => 'header',
+        'group' => JS_LIBRARY,
+        'every_page' => TRUE,
+        'weight' => -1,
+        'preprocess' => TRUE,
+        'cache' => TRUE,
+        'defer' => FALSE,
+        'browsers' => array(),
       );
       // Register all required libraries.
       drupal_add_library('system', 'jquery', TRUE);
