orestbida / cookieconsent

:cookie: Simple cross-browser cookie-consent plugin written in vanilla js
https://playground.cookieconsent.orestbida.com/
MIT License
3.68k stars 388 forks source link

[Feat]: partytown support #554

Closed zngly-vlad closed 11 months ago

zngly-vlad commented 11 months ago

Description

PartyTown is a library which lets you handle loading scripts off the main thread in separate workers. This can help speed up your site.

Partytown depends on the type="text/partytown" attribute. CookieConsent relies on type="text/plain" to work.

Proposed solution

The script needs to update from type="text/plain" to type="text/partytown". When this is done dynamically window.dispatchEvent(new CustomEvent('ptupdate')); needs to be run.

Additional details

No response

orestbida commented 11 months ago

Duplicate of https://github.com/orestbida/cookieconsent/issues/487.

You can use the data-type attribute to specify a custom type:

<script type="text/plain" data-type="text/partytown" data-cookiecategory="analytics">
    console.log("executed");
</script>
zngly-vlad commented 11 months ago

My apologies - will test this out and close it if all is good.

Really awesome project, keep up the great work!