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

Polyfilled scripts don't load if there aren't <script> tags #380

Open
zshall opened this issue Mar 4, 2024 · 0 comments
Open

Polyfilled scripts don't load if there aren't <script> tags #380

zshall opened this issue Mar 4, 2024 · 0 comments

Comments

@zshall
Copy link

zshall commented Mar 4, 2024

The problem:

I've been running into issues using Vime's HLS provider in SvelteKit on a browser that requires the hls.js library to function. My application is bundled with the output being <link rel="modulepreload" href="..."> tags, not <script src="..."></script> tags.

In the loadScript function which loads hls.js, line 62 queries for the first <script> tag on the page:

const firstScriptTag = document.getElementsByTagName('script')[0];

If there isn't one then the library can't be loaded.

A workaround:

You can modify SvelteKit's app.html to add an empty script tag which allows the loadSdk() call to work:

<!DOCTYPE html>
<html lang="en">
	<head>
		<script>// empty script tag to satisfy conditions for loadSdk();</script>
		%sveltekit.head%
	</head>
...

One potential fix may be that if there aren't any script elements a loaded library could be prepended to the <head> or appended to the <body>.

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

No branches or pull requests

1 participant