Skip to content

Commit

Permalink
Improved Vue/Turbo loading speed fix (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning authored Nov 27, 2024
1 parent eb859b2 commit 4d1a24c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions resources/js/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import './vue'
import './fetch'
import './filters'
import './mixins'
;(() => import('./turbolinks'))()
import './cookies'
import './callbacks'
import './vue-components'
import './turbolinks'

if (import.meta.env.VITE_DEBUG === 'true') {
document.addEventListener('vue:loaded', () => {
Expand Down Expand Up @@ -50,10 +50,12 @@ document.addEventListener('vue:loaded', () => {
}
})

let booting = false
function init() {
if (document.body.contains(window.app.$el)) {
if (booting || document.body.contains(window.app.$el)) {
return
}
booting = true

// https://vuejs.org/api/application.html#app-config-performance
Vue.config.performance = import.meta.env.VITE_PERFORMANCE == 'true'
Expand Down Expand Up @@ -189,6 +191,7 @@ function init() {
})

setTimeout(() => {
booting = false
const event = new CustomEvent('vue:loaded')
document.dispatchEvent(event)
})
Expand Down
2 changes: 1 addition & 1 deletion tests/DuskTestCaseSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function setUp(): void
/** @var Browser $this */
$this
->waitUntilIdle()
->waitUntilTrueForDuration('document.body.contains(window.app?.$el) && window.app?._isMounted && console.log("mounted") === undefined', 10, 1)
->waitUntilTrueForDuration('document.body.contains(window.app?.$el) && window.app?._isMounted', 60, 1)
->waitUntilIdle();

return $this;
Expand Down

0 comments on commit 4d1a24c

Please sign in to comment.