Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape </script> in library JS code for embedding #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

izelnakri
Copy link

@izelnakri izelnakri commented May 22, 2021

This single line of escaping was needed to be able to embed this string to any html inside <script> tags without having it as a separate js file.

Although the use-case for this is rare, it does happen when I bundle things with esbuild internally and embed the output js string on the fly to the requested html in qunitx, even bundled/transpiled output would preserve the string thus this change was needed.

Otherwise browsers try to close the JS early as it encounters the </script> inside the code which breaks the page/html rendering.

Related stack overflow issue: https://stackoverflow.com/questions/22488830/script-within-a-javascript-string-in-a-script-tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant