partytown icon indicating copy to clipboard operation
partytown copied to clipboard

Append script element with partytown is not working

Open niyazafazl opened this issue 2 years ago • 2 comments

I am using the below JS snippet to append the script element with partytown typefor the appdynamics library

export function asyncJs(url, elementName, onload = () => {}) {
	const el = document.createElement('script');
	el.setAttribute('src', url);
	el.setAttribute('type', 'text/partytown');
	el.setAttribute('async', true);
	el.onload = onload;
	const targetEl = document.getElementsByTagName(elementName)[0];
	return targetEl.appendChild(el);
}

But its not loaded the third party script from the partytown

image

Whereas the third party script that I directly added the partytown type is working fine.

image

Can you please advice what is the issue here.

niyazafazl avatar Apr 01 '22 14:04 niyazafazl

After I include the script tag with partytown.js, the appdynamic script loads from partytown webworker.

	const ptEl = document.createElement('script');
	const el = document.createElement('script');
	ptEl.setAttribute('src', '/~partytown/debug/partytown.js');
	ptEl.setAttribute('aync', true);
	el.setAttribute('src', url);
	el.setAttribute('type', 'text/partytown');
	el.setAttribute('async', true);
	el.onload = onload;
	document.head.appendChild(ptEl);
	document.head.appendChild(el);
	return document;

But for App Dynamics getting the below error when it loads from the partytown web worker. image

niyazafazl avatar Apr 01 '22 15:04 niyazafazl

hey @niyazafazl - we've just created an issue template, could you update your issue here to provide all the information the template asks for? it'll help us look into your issue https://github.com/BuilderIO/partytown/issues/new?assignees=&labels=&template=bug_report.md&title=

pasting below to make things easier:


Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Reproduction link Please include a link to a Stackblitz or Codesandbox reproducing the issue. We will need to see the issue reproduced with hand-written code - we can't debug giant minified third party scripts directly. If you do not include a clean and simple reproduction of your issue, we won't be able to look into it until you do.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

steve8708 avatar May 28 '22 19:05 steve8708

Closing this issue since it has become stale, or has been addressed in recent releases and docs updates. If you feel this is still an issue please reopen a new issue. Thanks.

adamdbradley avatar Mar 21 '23 15:03 adamdbradley