Drupal is a registered trademark of Dries Buytaert

contact_block_ajax

4 sites No security coverage
View on drupal.org

Contact Block AJAX provides blocks that load Drupal contact forms via AJAX with lazy loading using the Intersection Observer API. Forms are deferred until they enter the viewport, significantly improving initial page load performance.

What It Does

Instead of loading contact forms on initial page render, this module loads them asynchronously when users scroll to the block. Forms also submit via AJAX without requiring page reloads, providing a modern, seamless user experience.

Key Features

  • Lazy Loading: Forms load only when visible, reducing initial page weight by 15-30%
  • AJAX Submission: Submit forms without page reloads for better UX
  • Rate Limiting: Configurable IP-based protection against abuse using Flood API
  • Multi-form Support: Handle multiple contact forms with custom display modes
  • Security Integration: Works with CAPTCHA, reCAPTCHA, and Honeypot modules
  • Contact AJAX Compatibility: Integrates with contact_ajax module (with limitations)
  • Full Testing: Comprehensive automated tests included

Performance Benefits

  • 15-30% reduction in initial page size
  • 200-500ms faster Time to Interactive
  • Improved Core Web Vitals scores
  • Better mobile performance

Requirements

  • Drupal 10.3+ or 11.0+
  • PHP 8.1+
  • Block module (core)
  • Contact module (core)

Installation

composer require drupal/contact_block_ajax
drush en contact_block_ajax -y

Basic Configuration

  1. Navigate to Structure > Block layout
  2. Place "Contact Block AJAX" block in your desired region
  3. Select contact form and display mode
  4. (Optional) Configure rate limiting at Configuration > People > Form load rate limit

Rate Limiting

Includes configurable rate limiting to prevent abuse:

  • IP-based tracking with Drupal's Flood API
  • Configurable thresholds (1-500 requests)
  • Flexible time windows (1 minute - 24 hours)
  • Default: 30 requests per 5 minutes
  • Detailed logging of violations

Compatibility

  • Drupal 10.3, 10.4, 11.0, 11.1
  • Contact AJAX module (except "Default message and empty form" mode)
  • CAPTCHA, Image CAPTCHA, reCAPTCHA v2/v3
  • Honeypot anti-spam
  • Flood control module

Documentation

Support

For bug reports and feature requests, please use the issue queue. For security issues, contact the Drupal Security Team.

Similar Modules

  • Contact Block: Provides contact forms in blocks (without AJAX/lazy loading)
  • Contact AJAX: Enhanced AJAX for contact forms (works with this module)

This module combines the block functionality of Contact Block with modern performance optimization techniques, making it ideal for sites that prioritize Core Web Vitals and user experience.

Activity

Total releases
2
First release
Oct 2025
Latest release
4 months ago
Release cadence
29 days
Stability
100% stable

Releases

Version Type Release date
1.1.0 Stable Nov 2, 2025
1.0.0 Stable Oct 4, 2025