OOW PJAX DOCUMENTATION

Plugin Overview

OOW PJAX, developed by OOWCODE and OOWPRESS, transforms your WordPress site into a fast, seamless navigation experience using PJAX (PushState + AJAX). By replacing full page reloads with dynamic content updates, it delivers an app-like feel while maintaining compatibility with any WordPress theme. Built with pure JavaScript (no jQuery), version 1.4 introduces dynamic nonce refreshing, asynchronous stylesheet management, and enhanced form redirect handling, making it ideal for portfolios, blogs with persistent media players, e-commerce stores, or single-page app experiences.

How It Works

OOW PJAX intercepts internal link clicks and form submissions, loading content via AJAX and updating the browser’s URL using the History API. Key steps include:

  • Link Interception: Captures clicks on internal links, skipping external links, target="_blank", excluded selectors (e.g., .no-pjax), or zones (e.g., #wpadminbar).
  • AJAX Loading: Fetches new page content and scripts without reloading the entire page.
  • Content Update: Replaces specified containers (e.g., #main, .content) with new content.
  • URL Synchronization: Updates the browser’s URL for natural forward/back navigation.
  • Persistent Elements: Preserves fixed elements (e.g., media players, sticky headers) during transitions.
  • Style Management: Asynchronously injects page-specific stylesheets and inline styles for consistent rendering.
  • Script Management: Re-executes scripts in updated containers or footer with strict validation.
  • Form Handling: Submits forms via AJAX, supporting comment nonces and server-side redirects (301, 302, 303, 307, 308).
  • Caching: Stores pages locally for instant repeat visits (disabled for logged-in users).
  • Loading Indicator: Displays a customizable overlay during transitions with adjustable minimum duration.
  • Nonce Refreshing: Dynamically refreshes security nonces via AJAX for reliable requests.

Why Use OOW PJAX?

  • Lightning-Fast Navigation: Reduces load times by avoiding full page reloads.
  • Seamless User Experience: Delivers smooth, app-like transitions for better engagement.
  • Persistent Elements: Keeps media players, menus, or widgets active during navigation.
  • Lightweight & Modern: Uses vanilla JavaScript, no jQuery, for optimal performance.
  • Developer-Friendly: Offers custom JS execution, script priority control, and debug tools.
  • Secure Implementation: Employs dynamic nonces, sanitization, and script validation.
  • Theme-Agnostic: Works with any WordPress theme via customizable containers.
  • SEO-Friendly: Maintains proper URLs and history for search engine compatibility.
  • Advanced Form Handling: Supports complex form submissions with redirect handling and nonce refreshing.
  • Dynamic Styling: Ensures consistent rendering with asynchronous stylesheet management.

Configuration and Settings

Configure OOW PJAX in the Settings tab (OOWCODE > OOW PJAX > Settings). Below is a detailed breakdown of each setting:

SettingDescriptionValueUsageExample
Enable PJAX (oow_pjax_enabled)Activates or deactivates PJAX functionality.Checkbox (disabled by default)Check to enable PJAX; uncheck for standard WordPress navigation.Enable to start using PJAX.
Target Containers (oow_pjax_targets)HTML containers to update with AJAX content.Space-separated CSS selectors (default: #main)Specify IDs or classes for your theme’s content area. Inspect source code to find the correct container (e.g.,

).
#main .content updates multiple containers.
Exclude Selectors (oow_pjax_exclude_selectors)Links or elements to exclude from PJAX.Space-separated CSS selectors (empty by default)Bypass PJAX for specific links (e.g., popups, .no-pjax) or elements like #wpadminbar..no-pjax #player-controls excludes media player controls.
Exclude Selectors Zone (oow_pjax_exclude_zone_selectors)Zones containing links or forms to exclude from PJAX.Space-separated CSS selectors (default: #wpadminbar)Exclude entire sections (e.g., .footer) to skip all links and forms within..footer .sidebar excludes links in footer/sidebar.
Exclude External Links (oow_pjax_exclude_external)Excludes links to external domains.Checkbox (enabled by default)Prevent PJAX from loading external content (e.g., https://example.com).Uncheck only if external content loading is desired (rare).
Exclude Links with target=”_blank” (oow_pjax_exclude_target_blank)Excludes links opening in new tabs.Checkbox (enabled by default)Respects standard behavior of target="_blank" links. opens in a new tab without PJAX.
Enable Cache (oow_pjax_enable_cache)Caches pages for faster repeat visits.Checkbox (disabled by default)Enable for sites with frequent internal navigation. Disabled for logged-in users.Enable for a blog with heavy article browsing.
Cache Lifetime (oow_pjax_cache_lifetime)Duration (in seconds) pages remain cached.Integer (default: 300 seconds)Adjust based on content update frequency. Set to 0 for no expiration.3600 (1 hour) for static sites; 300 for dynamic sites.
Enable Debug Mode (oow_pjax_debug_mode)Logs detailed information in the browser console and server logs.Checkbox (disabled by default)Enable temporarily to diagnose issues (e.g., AJAX errors, selector issues).View logs in browser console (F12) or server error logs.
Enable Loader (oow_pjax_enable_loader)Shows a loading overlay during transitions.Checkbox (enabled by default)Inform users of loading. Disable for no visual indicator.Spinner appears during content loading.
Loader CSS (oow_pjax_loader_css)Customizes the loading overlay’s appearance.CSS code (default: circular spinner)Modify CSS for brand alignment. Use Reset to Default to revert.border: 5px solid #0073aa for a blue spinner.
Minimum Loader Duration (oow_pjax_min_loader_duration)Minimum loader display time (in milliseconds).Integer (default: 200 ms)Prevent loader from disappearing too quickly on fast connections.500 ms ensures visibility for half a second.
Enable Form Handling (oow_pjax_enable_forms)Submits forms via AJAX.Checkbox (disabled by default)Enable for seamless form submissions (e.g., comments, login). Supports comment nonces and redirects (301, 302, 303, 307, 308).Comment form submits without reloading.
Target Refresh Containers (oow_pjax_form_refresh_targets)Additional containers to refresh after form submission.Space-separated CSS selectors (empty by default)Update specific areas (e.g., comments section) after form submissions.#comments .comment-form refreshes comment area.
Script Priority (oow_pjax_script_priority)Sets the loading order of oow-pjax.js in the footer.Integer (default: 9999)Use a high value to load PJAX after other scripts for compatibility.9999 ensures late loading.

Custom JS Configuration: In the Custom JS tab, add JavaScript to execute before or after PJAX navigation using CodeMirror with syntax highlighting and a Dracula theme. Example: Trigger analytics (gtag('event', 'pjax_load')) or reinitialize a slider ($('.slider').slick()).

Tips for Optimal Configuration

Identify Theme Containers

  • Inspect source code (right-click > Inspect) to find the main content container (e.g., #main, .content).
  • Test with one selector before adding multiple to avoid conflicts.

Test Exclusions

  • Add .no-pjax to links bypassing PJAX (e.g., PDFs, popups).
  • Exclude persistent elements like media player controls (e.g., #player-controls) or zones (e.g., .player).

Customize the Loader

  • Modify Loader CSS to match your brand (e.g., use theme colors).
  • Ensure visibility on all devices, including mobile.

Optimize Script Loading

  • Set Script Priority to a high value (e.g., 9999) if other scripts conflict with PJAX.
  • Use Custom JS to reinitialize scripts (e.g., sliders, analytics) after navigation.

Style Management

  • Version 1.4 automatically manages page-specific stylesheets and inline styles asynchronously to prevent duplicates.
  • Verify styles load correctly in the browser’s developer tools.

Form Handling

  • Test all forms (e.g., Contact Form 7, login) with Enable Form Handling enabled.
  • Use Target Refresh Containers to update areas like #comments after submissions.
  • Dynamic nonce refreshing ensures reliable form submissions during long sessions.

Use Debug Mode

  • Enable Debug Mode to log AJAX requests, script execution, and errors.
  • Check the console (F12) or server error logs for detailed information.

Test Caching

  • Enable Enable Cache and set Cache Lifetime for frequently visited pages.
  • Ensure dynamic content (e.g., comments) updates correctly with caching plugins like WP Rocket.

Example Configuration

For a WordPress site using a theme like Astra with a persistent audio player:

  • Enable PJAX: Enabled
  • Target Containers: #main .content
  • Exclude Selectors: .no-pjax #player-controls .wp-block-button
  • Exclude Selectors Zone: .player .footer
  • Exclude External Links: Enabled
  • Exclude Links with target=”_blank”: Enabled
  • Enable Cache: Enabled
  • Cache Lifetime: 3600 (1 hour)
  • Enable Debug Mode: Disabled (enable for troubleshooting)
  • Enable Loader: Enabled
  • Loader CSS: border: 5px solid #0073aa (theme color)
  • Minimum Loader Duration: 300 ms
  • Enable Form Handling: Enabled
  • Target Refresh Containers: #comments .comment-form
  • Script Priority: 9999
  • Custom JS Before: console.log('PJAX navigation started');
  • Custom JS After: gtag('event', 'pjax_load'); $('.slider').slick();

Troubleshooting

Content Not Loading

  • Verify Target Containers selectors are correct (e.g., #main exists).
  • Enable Debug Mode to check console and server logs for AJAX errors.

Loader Not Displaying

  • Ensure Enable Loader is checked and Loader CSS isn’t overridden.
  • Check for conflicting CSS in the browser’s developer tools.

Scripts Not Executing

  • Verify Script Priority is high enough (e.g., 9999) to avoid conflicts.
  • Use Custom JS After to reinitialize scripts (e.g., $('.slider').slick()).

Styles Not Applying

  • Check browser tools to ensure stylesheets load without duplicates.
  • Enable Debug Mode to log stylesheet application errors.

Forms Not Working

  • Test without Enable Form Handling to isolate issues.
  • Ensure form plugins (e.g., Contact Form 7) are compatible with AJAX submissions.
  • Verify dynamic nonce refreshing is functioning (check console logs).

Plugin Conflicts

  • Add conflicting plugin selectors to Exclude Selectors or Exclude Selectors Zone.
  • Temporarily disable other plugins to identify conflicts.

Support