Interactivity outside blocks or as "standalone" (like Alpine.js)? #60979
Replies: 2 comments 11 replies
-
Hi @Niq1982 👋 I'm not entirely sure if this is what you meant, but you can easily use Interactivity API "standalone" without even needing WordPress: https://stackblitz.com/edit/vitejs-vite-7kjzrb?file=index.html You can use the
At the moment this is not planned, for a few reasons:
|
Beta Was this translation helpful? Give feedback.
-
I've opened a PR to achieve this a few months back in #61681 however it saw little interest so far so Ive closed it. Happy to re-open if there's further interest in a "standalone" build. |
Beta Was this translation helpful? Give feedback.
-
Was there any intentions to make Interactivity API work as "standalone", so you could use it just anywhere to build interactivity, like Alpine.js does really beautifully? Or to use it outside blocks? Now you can basically do nothing with it unless you set up a local environment and create&run a build process to get the store set up, which kinda rules out most of non-professionals building sites around the world. If you could create the store with it's functions within the html template, it would be easy not to just create interactivity to new projects, but also build stuff to older, non-block projects as well. Interactivity API could then potentially help to get rid of jQuery, since it would make even easier to build small JS interactions than it is with jQuery.
Other IMO huge limiting issue is not to be able to run code or even set values on
data-wp-on
directive like<button data-wp-on--click="context.open = ?context.open">
. Is there any plans to make this possible in the future?Beta Was this translation helpful? Give feedback.
All reactions