Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module provides blocks that load Drupal contact forms using AJAX with lazy loading, meaning forms are only loaded when they scroll into view to improve initial page load performance. It also allows forms to be submitted via AJAX without a page refresh.

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
8 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Slowing

Releases

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