Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ekpono's avatar
Level 12

Endpoint that loads javascript file without javascript extension

0

I am building a widget, the code snippet that loads the widget is created dynamically just like tawk.to works.

Example of the code snippet might look like this

(function(){
    var s1=document.createElement("script"),
        s0=document.getElementsByTagName("script")[0];

    s1.async=true;
    s1.src='https://embed.tawk.to/*8jjnjk*****1/****1gf****';
    s1.charset='UTF-8';
    s1.setAttribute('crossorigin','*');

    s0.parentNode.insertBefore(s1,s0);
})();

Now, if you look at the https://embed.tawk.to endpoint it loads just the js file. How do I create something like that, an endpoint that loads another javascript file so that I can get user information from the first url before initializing the main Widget.

Any reference would be highly appreciated

0 likes
0 replies

Please or to participate in this conversation.