Webflow sync, pageviews & more.
NEW

How can Webflow Interactions still be triggered and work after using third party integrations like barba.js v2?

TL;DR
  • Use Barba.js's afterEnter() hook to manually reinitialize Webflow interactions by calling Webflow.require('ix2').init();.
  • Optionally use Webflow.destroy(); before reinitializing to prevent duplicates, and call Webflow.ready(); for other components like forms and sliders.

When using barba.js (v2) for transitions in a Webflow site, Webflow interactions may stop working because Webflow requires a full page reload to initialize its interactions. Barba.js prevents that by using PJAX to load pages via AJAX, so Webflow’s default interaction system doesn't reinitialize.

1. Understand the Conflict

  • Webflow Interactions are initialized on page load or DOM ready events.
  • Barba.js replaces only the inner container of the page, not doing a full reload, which means Webflow doesn’t detect the DOM change.
  • As a result, Webflow interactions won’t reinitialize automatically after a barba.js transition.

2. Use Webflow’s Webflow.require API

  • You can manually reinitialize interactions after each Barba transition using:
    Webflow.require('ix2').init();
  • Place this call inside Barba’s afterEnter or after hook.

3. Set Up Barba Hooks Correctly

  • In your Barba config, locate the afterEnter() or after() lifecycle hook.
  • Inside that hook, call:
  • Webflow.destroy(); (optional but helps avoid interaction duplication if needed)
  • Webflow.require('ix2').init(); to restart interactions
  • Webflow.ready(); if forms or other components need to reinit

Example placement in Barba v2:

  • In the afterEnter() callback:
  • Clean up and reinit:
    • Optional: Webflow.destroy();
    • Required: Webflow.require('ix2').init();
    • Optional: Webflow.ready();

4. Ensure Global Scripts and Assets Are Not Lost

  • Any third-party scripts declared directly in page settings (like analytics or chat widgets) may not reload on transition.
  • Place critical scripts in the main layout (e.g., custom code in the Webflow site settings or the global custom code blocks) so they load once and persist.

5. Reinitialize Other Webflow Components (Optional)

  • If using Webflow’s CMS filtering, sliders, or tabs, you may also need to reinitialize them. Webflow doesn’t expose public APIs for all of them, but re-running Webflow.ready(); often helps.

Summary

To make Webflow interactions work with Barba.js (v2), manually reinitialize them after each page transition:

  • Add Webflow.require('ix2').init(); inside Barba’s afterEnter() hook.
  • Optionally call Webflow.destroy(); before that to clear old interactions.
  • Use Webflow.ready(); if other Webflow components (forms, sliders) are not behaving correctly.

This ensures interactions behave as expected after dynamic transitions.

Rate this answer

Other Webflow Questions