[✨] Partial URL matching in "loadScriptsOnMainThread"
BonoBelarus opened this issue · comments
Bono commented
Is your feature request related to a problem?
Currently, the "loadScriptsOnMainThread" option uses strict string equality to determine if a script should be executed on the main thread. However, this approach is not flexible when URLs contain query parameters.
Describe the solution you'd like
I suggest changing this behavior to partial string matching or allowing the use of regular expressions to match URLs.
Something like this
// index.html
window.partytown = {
...
loadScriptsOnMainThread: ["https://googleads.g.doubleclick.net/pagead/viewthroughconversion/"],
}
// partytown-ww-sw.js
// url may be like: "https://googleads.g.doubleclick.net/pagead/viewthroughconversion/123123123/?random=123123&cv=12&fst=1232123&bg=ffffff&guid=ON&..."
const shouldExecuteScriptViaMainThread = config.loadScriptsOnMainThread.some(
scriptUrl => decodeURIComponent(url).includes(scriptUrl),
)
Describe alternatives you've considered
Additional context
No response