Skip to content

Commit

Permalink
fix(entry): added global var for force init
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornWalli committed Dec 19, 2022
1 parent 7e89cef commit e3c56a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/templates/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { isSupportedBrowser } from 'nuxt-speedkit/utils/browser';
let initialized = false
const layerEl = global.document.getElementById('nuxt-speedkit-layer');

const forceInit = ('__NUXT_SPEEDKIT_FORCE_INIT__' in global && global.__NUXT_SPEEDKIT_FORCE_INIT__);

const triggerRunCallback = sufficient => global.dispatchEvent(new CustomEvent('nuxt-speedkit:run', { detail: { sufficient } }))

async function initApp(force) {
Expand Down Expand Up @@ -87,7 +89,7 @@ const supportedBrowser = isSupportedBrowser(<%= options.supportedBrowserDetector

window.addEventListener('load', function () {
if (!document.getElementById('nuxt-speedkit-layer')) {
initApp();
initApp(forceInit);
} else {

observeSpeedkitButton('nuxt-speedkit-button-init-reduced-view', initReducedView);
Expand Down

0 comments on commit e3c56a1

Please sign in to comment.