I haven't yet found a way to consistently prevent Phoenix Live Views from removing elements from the DOM that were put there by JavaScript. Here is a snippet from a crude chat app that uses JavaScript to add a smiley face after the page loads:
<span><%= live_patch "New Chat", to: Routes.chat_index_path(@socket, :new) %></span>
<div id="smiley" style="font-size: 80px" phx-update="ignore"></div>
<script>
$(document).ready(function() {
$('#smiley').html('')
});
</script>
The phx-update="ignore"
attribute prevents the smiley face from disappearing right away, but adding a new chat causes it to disappear: