I’ve been using JS.push primarily since it seems more in-tune with what’s actually happening right? I’m pushing an event to my liveview using JS on the frontend.
I use the JS command when I need to run another JS command that will do something else that doesn’t need to go to the server AND push an event so I can pipe them.
phx-click={JS.hide(transition: "fade-out", to: "#modal") |> JS.push("save_rating", value: %{rating: 4})}
If I only need to send the event, I prefer using the phx- bindings. This approach also makes it easier to test because you can select elements based on their events, if you use the JS commands you need to work around this limitation.