Native JS Events in Elementor

Elementor was originally developed using jQuery. This means the editor, and many components that trigger events, had to use jQuery events. The issue with jQuery events is that they are not native JS events wrapped in a jQuery method, they utilize a completely separate mechanism. This led to frustration within the external developers community as developers couldn’t listen to events using the addEventListener() method – they were forced to use jQuery .on() method.

Dual Support

To address the issue, we mapped all the events Elementor triggers, in the frontend. Elementor 3.5 introduced an event dispatch method that triggers both jQuery events and native JS events. In Elementor Pro 3.7 we brought the same capabilities to Pro.

Instead of the following:

jQuery( window ).on( 'elementor/event/name', () => { /* … */ });

Developers can now use vanilla JS events, like so:

window.addEventListener( 'elementor/event/name', () => { /* … */ });

Both versions are currently supported. Saying that, we do encourage addon developers to adopt vanilla JS to prepare your code for the moment Elementor abandons jQuery.

Issue Origins

When triggering JS events, Elementor had inconsistent naming conventions. Some events use colons between namespace elements, and others use slashes. Using colons is a jQuery convention, but vanilla JS events do not support the use of colons in the event name (e.g elementor:init v.s elementor/init).

Essentially, by relying on events with colons, Elementor forced addon developers to use jQuery. This is no longer true –  all events have been renamed to use slashes. The old event names with colons still work, but you can only catch them with jQuery. The new event names can be listened to using jQuery and vanilla JS.

Please note that events with colons in their names will be eventually deprecated.

Backward Compatibility

If you plan to adopt JS events, and your addon has compatibility checks, make sure to update the minimum required Elementor version to 3.5 and minimum required Elementor Pro version to 3.7.

Author

Rami Yushuvaev
Rami Yushuvaev
Head of Elementor Developers Experience. Fullstack developer. Open source projects contributor. Creator of ChartsCSS.org, GenerateWP.com, DisplayWP.com and many other projects.

2 Responses

  1. “Saying that, we do encourage addon developers to adopt vanilla JS to prepare your code for the moment Elementor abandons jQuery.”

    Any idea when this might happen? It’s 2024 we don’t need to be running jquery anymore.

Leave a Reply

Your email address will not be published. Required fields are marked *