Empower developers with tools that assist with developing and debugging the frontend or backend of the site.

Asynchronous JavaScript

Load JavaScript asynchronously using the most browser compatible method. The

element for each JavaScript file to be loaded asynchronously will be generated dynamically after the window load event using the following basic method:
(function() {
  var s = document.createElement('script');
  s.type = 'text/javascript';
  s.async = true;
  s.src = script.data;
  var x = document.getElementsByTagName('script')[0];
  x.parentNode.insertBefore(s, x);
})();

How to load a JavaScript file asynchronously

Using this module, you can specify a script to be loaded asynchronously in two basic ways:
  1. By adding "async_js" => TRUE to the options array in drupal_add_js().
  2. By calling async_js_add_js("path/to/your/script.js") which bypasses drupal_add_js(), gets you the same result, and may be a touch faster.

Additional functionality

Dependencies:

Specify dependencies at the individual script level. Simply add "async_dependencies" => array("path/to/script1.js", "path/to/script2.js") to the options array in either drupal_add_js() or async_js_add_js(). NOTE: The path you use to reference the dependency must correspond exactly to the path used to actually load the dependency.

Callback functions:

Specify callback functions to be fired once the script has loaded. This can be done by adding "async_callback" => array("your_function_name", "another_function_name") to the options array in either drupal_add_js() or async_js_add_js(). NOTE: All callback functions must exist in the global scope.

Fade-in effect:

When specifying a script to be loaded asynchronously, you can specify html elements to fade in after a delay and in unison. This can be done by adding "async_fade" => array(".array", "#of", ".jQuery", "#selectors") to the options array in either drupal_add_js() or async_js_add_js(). The fade-in effect will be applied universally to all elements defined in this way on a single page. The default delay is 1 second. This can be changed by editing the conf variable "async_js_timeout".

Containers:

Specify a container in which to append your script element. To do this, add "async_container" => ".jQuery #selector" to the options array in either drupal_add_js() or async_js_add_js().

Final callback:

You may add a final callback function to be fired after all asynchronous scripts have been successfully loaded by editing the "async_js_final_callback" conf variable. NOTE: Your callback function must exist in the global scope.

Similar modules

Development sponsored by Prima Supply.

Fancy Form API

Fancy Form API is inspired from #states property of Drupal Form API

Component Installer

Component Installer allows installation of Components (third-party JavaScript and CSS packages) through Composer. This module facilitates its use for Drupal.

Dependencies

Usage

  1. Add the Components you want to your module's composer.json file:
    {
        "require": {
            "components/underscore": "*",
            "components/normalize.css": "*"
        }
    }
    
  2. Make your module depend on component_installer in your .info file:
    dependencies[] = component_installer
    
  3. Use Composer Manager to help build and install the Composer dependencies.
  4. The Component's JavaScript is now available for use through require.js:
    require(['underscore'], function (_) {
      // Underscore is now available.
      _.each([1, 2, 3], alert);
    });
    
  5. Any CSS that the Component provides is automatically loaded.

Available Components

DM User Picture Crop

DM User Picture Crop is a Drupal utility module based on jQuery that lets you crop your profile images when you upload them.

UI Cache Clear

UI Cache Clear

Adds contextual link “Clear cache” for:

  • Blocks
  • Views
  • Panels
  • Path Breadcrumbs
  • Entity cache and Display Cache (for nodes only)

Adds link for clearing current page cache (Boost supported too).

Features:

  • Clears specific cache bin without flushing the whole site cache.
  • Allows to clear cache without full administrator permissions.
  • Provides setting to clear current page cache automatically when clearing Block, Views or Panels cache.
  • Admin menu and Shortcut integration

To access “Clear cache” link user needs permissions “Use contextual UI Cache Clear links” and “Use contextual links” of course!

Designed for both development and production.

Pages

Subscribe with RSS Subscribe to RSS - Developer tools