Sage 10 move scripts back into head

Hi!
I need to move the scripts back into head
But how does that work with sage 10?
I tried this but it is not working

add_action('wp_enqueue_scripts', function () {
    bundle('app')->enqueue();
}, 100, false);

Do you need to? Can you help us understand why?

You would need to use the enqueueJs function:

I’m trying to get howire turbo to work, but I’m getting this error

Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': the name "turbo-frame" has already been used with this registry

And moving the scripts back into the head fixes this error
or is there a better way to do this?

You are loading Turbo from a <script> element inside the <body> element. This is probably not what you meant to do!

Load your application’s JavaScript bundle inside the <head> element instead. <script> elements in <body> are evaluated with each page change.

For more information, see: https://turbo.hotwired.dev/handbook/building#working-with-script-elements

This lets me load the JS in the head (and removes the error) but now somehow breaks my swiper slider

add_action('wp_enqueue_scripts', function () {
    bundle('app')->enqueueCss()->enqueueJs(false);
}, 100);
1 Like