How to know if jQuery UI is being included Is there a good way of checking for if jQuery UI is being included on the current page request?

Found drupal_get_library(), and drupal_add_library(), but neither of them allows me to check if it is being included.

I am trying to do this from the theme, and then load a jquery.ui.touch-punch library to enable iPad/iPhone support.
There's no built in way but as drupal_add_library() uses Drupal's static pattern you can find out by doing this:

function ui_is_included() {
  // Get the list of libraries included in this page load
  $libs = drupal_static('drupal_add_library');

  // The system library will pretty much always exist as it includes jQuery,
  // but it's just good sense to check just in case.
  if (isset($libs['system'])) {
    // If the system library array includes UI then make sure it's enbabled
    return isset($libs['system']['ui']) &amp;&amp; $libs['system']['ui'] === TRUE;
  }

  // UI is not loaded if we've got to this point
  return FALSE;
}


You can even compress that down a bit:

function ui_is_included() {
  $libs = drupal_static('drupal_add_library');
  return isset($libs['system']['ui']) &amp;&amp; $libs['system']['ui'];
}


I'd advise calling this function as late on in the page build process as possible, to ensure that all modules have had a chance to request that UI is added. hook_preprocess_html() in your theme's template.php file might be a good place to put it.