BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. šŸŽ‰
https://partytown.builder.io
MIT License
13.06k stars 434 forks source link

[šŸž] Intercom does not work with party town #602

Open dbelouslv opened 4 months ago

dbelouslv commented 4 months ago

Describe the bug

Good morning! I have a problem with Intercom and partytown. These lines from head. If I remove patrytown scripts and type="text/partytown" Intercom works.

 <script>
     partytown = {
         forward: ['Intercom']
     };
 </script>

 <script type="module" src="/~partytown/partytown.js"></script>

 <script type="text/partytown">
    window.intercomSettings = {
        api_base: "https://api-iam.intercom.io",
        app_id: "xxx",
    };
</script>

<script type="text/partytown">
    (function () { var w = window; var ic = w.Intercom; if (typeof ic === "function") { ic('reattach_activator'); ic('update', w.intercomSettings); } else { var d = document; var i = function () { i.c(arguments); }; i.q = []; i.c = function (args) { i.q.push(args); }; w.Intercom = i; var l = function () { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://widget.intercom.io/widget/xxx'; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); }; if (document.readyState === 'complete') { l(); } else if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })();
</script>

image

And vite.config.js example:

export default defineConfig({
    base: '/',
    plugins: [
        vue({
            template: {
                compilerOptions: {
                    whitespace: 'preserve'
                }
            }
        }),
        partytownVite({
            dest: fileURLToPath(new URL("./public/~partytown", import.meta.url)),
        })
    ]
});

Reproduction

''

Steps to reproduce

Open the website

Browser Info

Chrome last version, in Mozilla it works

Additional Information

Vite: 5.1.3 Vuejs 3.4.19

corymharper commented 3 months ago

Just ran into this myself, any workarounds?

anoam99 commented 2 months ago

Same here... any updates?

AnaIftimie commented 1 month ago

Confirm, I'm having the same problem, with Intercom: image I made a code pen here or a fiddle here while I was testing this issue using Intercom and Userway, but as @dbelouslv said changing the type to simple javascript and the widgets show. With the type to partytown nothing works. Any updates?