External Dom modifying js libraries

Hello fellas,

I have been looking at customer help desk solutions and LiveAgent got my attention. And I would like to ask if their concept can somehow be used with elm because I can’t seem to get it right.

The idea is that they give you a scrpt like the following

<script type="text/javascript">
(function(d, src, c) { var t=d.scripts[d.scripts.length - 1],s=d.createElement('script');s.id='la_x2s6df8d';s.async=true;s.src=src;s.onload=s.onreadystatechange=function(){var rs=this.readyState;if(rs&&(rs!='complete')&&(rs!='loaded')){return;}c(this);};t.parentElement.insertBefore(s,t.nextSibling);})(document,
'https://companyname.ladesk.com/scripts/track.js',
function(e){ LiveAgent.createButton('fuyr39qr', e); });
</script>

Which you have to copy and paste just before your closing html tag.
I have tested it with a plane html file and what it does is using an i frame to invoke code which generates the neccecery widgets in your page, but as I expected it does not work just like that with elm because of the dom modifications I guess.

So questions is: Is there any way that I can integrate such a “library” with elm or is it just not gonna work for me ?

Any directions will be greatly appriciated!

I found out that the particular code acts uppon a node,
and I modified the node to be a custom element and the above code is being called
after the node is rendered from elm (through the connectedCallback) to the page and so I now have the expected behaviour.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.