Important note

As we have re-merged this fork module with its original role model there will be no more development this module here. We recommend that you replace js_callback with js in order to receive further update information. The js module now provides every feature which was added in this fork module.

Thanks for your support and understanding!


Overview

This project targets module developers and provides a "bare bone" callback handler which is intended to be addressed by modules wanting to improve response times for specialized tasks.

The idea of such a callback handler was first introduced by http://drupal.org/project/js (which we hence sometimes refer to as the "original module"). The D6 branch of js_callback was a clone of it and originally intended as a workaround to fix some issues which had been addressed there for a while. In the long run, we still intend re-merging both projects to avoid confusion.


Background and purpose

Drupal handles all requests - except those for public files - involving a standardized and complex bootstrap and database logic. Although that makes sense in most classic REST requests and is highly recommended for standard tasks due to caching and security reasons, it may cause a lot of performance cost on well frequented sites with much AJAX functionality.

JS_CALLBACK does not really do anything itself but instead provides an API to other developers who want to improve their project's AJAX (, SOAP, AHAH, JSON etc) performance. This is mainly achieved with bypassing a lot of Drupal core functions which are not needed in every case, and by allowing to determine which core functionality will be loaded on a per-request base.

Example

Think of a module which is only used for signaling that a user is still on your site. You might want to implement a JS interval who frequently tells the server "hi, this is session X with session cookie Y telling you that I'm still alive". You would not need any localization, forms API or theme engine involved to handle such a request properly, but think of the server load such a function would cause with some 100 users hailing every, say, 10 seconds using a complete Drupal request.

Requirements

  • Your server must support URL rewrites. E.g. in Apache, you need mod_rewrite enabled.
  • Clean URLs need to be activated in your Drupal setup.

Modules known to support JS_CALLBACK

If your module also supports the JS_CALLBACK and you want it listed here, please tell us.

Installation, setup and API

Please check with the included readme.txt.

Migration from JS module

If you migrate from js to js_callback, you don't need to alter anything. Just replace the js folder in sites/all/modules with the js_callback folder and copy the revised js.php into your Drupal root directory as before (you will of course need to properly de/activate the modules in admin/build/modules). Also all integration works as before, regarding hook_js() definitions and menu paths.

Security warning

Please do always remember that bypassing the Drupal core bootstrap means bypassing built-in security checks. You will have to take care all by yourself for protecting non-public menu callbacks and functions from unwanted access. You have been warned.
However, in the D7 version, you may now define access checks just as you would in hook_menu(). We might backport this to D6 if someone requests that.

Differences to JS module

Note: This section only refers to the D6 branch as there is no D7 release of "the original" JS module.

Project status, development

  • D6 The release is ready and working.
  • D7 michielnugter has just joined and already done a lot on the first D7 draft, sponsored by synetic.nl. It is available as a dev snapshot now. Please test and report bugs.

Project information

Releases