Overview
JS Callback Handler is a solution for creating highly performant server requests. This includes, but is not limited to, creating simple JSON callbacks.
This API is intended for module developers who wish to provide more of a "lean" approach to the Drupal bootstrapping process (not the front-end framework).
Note: this API does nothing by itself. It requires other modules to leverage its functionality and APIs.
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 Handler) 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.
Apache benchmarks
index.php:
ab -n20 -c1 http://example.com/index.php?q=js/mymodule/callback
Requests per second: 2.24 [#/sec] (mean)
Time per request: 446.846 [ms] (mean)
js.php:
ab -n20 -c1 http://example.com/js.php?q=js/mymodule/callback
Requests per second: 16.84 [#/sec] (mean)
Time per request: 59.371 [ms] (mean)
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.
Integration
Contributed (third-party) modules that support the high-performance JavaScript/AJAX callback handler:
Blog posts
You can find an excellent post about the JS module (with an example) by another Drupal enthusiast here:
http://www.pixelite.co.nz/article/high-performance-ajax-callbacks-drupal-7-and-js-module
8.x
This project is unnecessary in D8 as core has rest and jsonapi built in.
Project information
- Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed. - Maintenance fixes only
Considered feature-complete by its maintainers. - Module categories: Developer Tools, Performance
- 513 sites report using this module
- Created by sun on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 7.x-2.x-dev updated 16 Oct 2020 at 14:09 UTC