blob: 10f842c0ea7dcaff9e2e468daff57700e123e036 [file] [log] [blame]
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {getTrustedScriptURL} from 'chrome://resources/js/static_types.js';
let lazyLoadPromise: Promise<void>|null = null;
/**
* @return Resolves when the lazy load module is imported.
*/
export function ensureLazyLoaded(): Promise<void> {
if (!lazyLoadPromise) {
const script = document.createElement('script');
script.type = 'module';
script.src = getTrustedScriptURL`./lazy_load.js`;
document.body.appendChild(script);
lazyLoadPromise = Promise
.all([
'profile-type-choice', 'profile-switch',
].map(name => customElements.whenDefined(name)))
.then(() => {});
}
return lazyLoadPromise;
}