Skip to content

Commit

Permalink
Load Statamic scripts using DOMContentLoaded instead of a data src
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Oct 5, 2023
1 parent 6b236c7 commit cb96b14
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions resources/views/partials/scripts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
<script>
var StatamicConfig = @json(array_merge(Statamic::jsonVariables(request()), [
'wrapperClass' => $__env->getSection('wrapper_class', 'max-w-xl')
]))
</script>
]));
{{-- Deferred to allow Vite modules to load first --}}
<script src="data:text/javascript;base64,{{ base64_encode('Statamic.config(StatamicConfig); Statamic.start()') }}" defer></script>
window.addEventListener('DOMContentLoaded', () => {
Statamic.config(StatamicConfig); Statamic.start();
});
</script>

0 comments on commit cb96b14

Please sign in to comment.