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

[4.x] Load Statamic scripts using DOMContentLoaded instead of data: #8812

Closed
wants to merge 1 commit into from

Conversation

ryanmitchell
Copy link
Contributor

Go back to using DOMContentLoaded to keep the script inline and therefore avoid a one line .js file

Fixes #8795

@ryanmitchell ryanmitchell changed the title Load Statamic scripts using DOMContentLoaded instead of data: [4.x] Load Statamic scripts using DOMContentLoaded instead of data: Oct 5, 2023
@jasonvarga
Copy link
Member

I wonder if we can just do this instead:

<script type="module">
	Statamic.config(StatamicConfig);
	Statamic.start();
</script>

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#module

This value causes the code to be treated as a JavaScript module. The processing of the script contents is deferred.

@ryanmitchell
Copy link
Contributor Author

We could but no guarantee it would load before the vite modules which seemed to be why it needed to be deferred. I can never get vite working with the CP so I'm probably the wrong person to work on this.

@jasonvarga
Copy link
Member

It says that by using type="module" it gets deferred.

@jasonvarga
Copy link
Member

But no worries, we'll tinker with that. Thanks for the start!

@jasonvarga jasonvarga closed this Oct 5, 2023
@ryanmitchell ryanmitchell deleted the fix/data-script-csrf branch December 2, 2023 22:22
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.

data:text/javascript;base64 in start up and CSP headers
2 participants