Skip to content

Does Blits support dynamically registering custom components to a component's components: {} configuration? Is it possible to dynamically insert components into a template? #618

@kingway188

Description

@kingway188

We are developing a set-top box web system using blits, similar to the Android TV system. The code includes many modules and many JS files.
Currently, all JS files are statically imported, which makes the app startup very slow, taking more than 8 seconds to load and display the page.

For example, importing Settings.js will simultaneously parse and evaluate a large number of submodules (about 15+ settings/Osd files), which can cause a blockage of several seconds on low-performance devices—resulting in the 4s+ delay you see.

So I tried some lazy loading methods with Copilot's help, which could display the necessary components when loading the main page, and then dynamically load other components later.

such as:
Option 1: Lazy loading + conditional import => await import('../settings/Settings.js');
Option 2: Unified dynamic component container
Option 3: Route-level lazy loading => {
{ path: 'settings', component: () => import('./settings/Settings.js') },
{ path: 'applist', component: () => import('./home/OverlayApplist.js') },
{ path: 'add-fav-app', component: () => import('./home/OverlayAddFavApp.js') },
// ... (route can not show overlay with components)

I think if Blits support dynamically registering custom components to a component's components: {} configuration.we can dynamically insert components into a template. if so ,we can load other components later with Lazy loading + conditional import as overlay compoments.

Therefore, we would like to ask about this issue, and any suggestions would be appreciated.

Many Thanks

======
Currently source code tree:
.
|-- App.js
|-- api
| |-- ConfirmDialogManager.js
| |-- DataManager.js
| |-- FetchApi.js
| |-- MessageBoxManager.js
| |-- NetworkManager.js
| |-- PlayerManager.js
| |-- StorageManager.js
| -- data | |-- DataApps.js | -- DataChannels.js
|-- app
| |-- LiveTV
| |-- MediaCenter
| -- ShakaPlayer | -- ShakaPlayer.js
|-- components
| |-- Appcard.js
| |-- Background.js
| |-- Button.js
| |-- ButtonBig.js
| |-- Checkbox.js
| |-- ConfirmDialog.js
| |-- Grid.js
| |-- Input.js
| |-- Item.js
| |-- ItemOptions.js
| |-- Keyboard.js
| |-- List.js
| |-- Loader.js
| |-- MsgBox.js
| |-- OpLoading.js
| |-- OptionApplist.js
| |-- OptionFavorite.js
| |-- OptionItem.js
| |-- PortalItem.js
| |-- PortalRow.js
| |-- ProgressBar.js
| |-- ProgressBarShort.js
| |-- ResultScreen.js
| |-- Spinner.js
| |-- Square.js
| |-- StatusIcon.js
| |-- StatusRow.js
| |-- Toggle.js
| -- Toggles.js |-- home | |-- OverlayAddFastCh.js | |-- OverlayAddFavApp.js | |-- OverlayApplist.js | |-- OverlayCustomizeChannels.js | -- Portal.js
|-- index.js
|-- menu
| |-- MenuItemOneLine.js
| |-- MenuItemOneLineText.js
| |-- MenuItemSelectApp.js
| |-- MenuItemToggle.js
| |-- MenuItemToggleText.js
| |-- MenuItemTwoLine.js
| |-- MenuItemTwoLineText.js
| |-- MenuItemTwoLineTextToggle.js
| |-- MenuItemWifi.js
| |-- MenuSubTitle.js
| -- MenuTitile.js -- settings
|-- ColorSpaceSelect.js
|-- DeviceAbout.js
|-- DeviceAccessibility.js
|-- DeviceDateTime.js
|-- DeviceDeveloper.js
|-- DeviceDisplaySound.js
|-- DeviceEnergySaver.js
|-- DeviceHomeScreen.js
|-- DeviceKeyboard.js
|-- DeviceLanguage.js
|-- DeviceLocation.js
|-- DeviceMain.js
|-- DeviceStorage.js
|-- DeviceUsageDiagnostics.js
|-- DisplayHDMICEC.js
|-- DisplayModeSelect.js
|-- DisplayPictureSettings.js
|-- DisplayScreenPosition.js
|-- DisplayScreenResolution.js
|-- DisplaySoundMain.js
|-- HDRPolicySelect.js
|-- OsdAddNewNet.js
|-- OsdBluetoothSearch.js
|-- OsdCanNotLoginIn.js
|-- OsdFactoryReset.js
|-- OsdIPsetting.js
|-- OsdProxySetting.js
|-- OsdReadyLoginIn.js
|-- OsdRestart.js
|-- OsdWifiConnect.js
|-- Settings.js
|-- SettingsAccounts.js
|-- SettingsApps.js
|-- SettingsDevice.js
|-- SettingsMain.js
|-- SettingsNetwork.js
|-- SettingsRemote.js
|-- SoundDigitalOutput.js
|-- SoundOutputFormat.js
`-- SoundVolumeControl.js

11 directories, 98 files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions