-
Notifications
You must be signed in to change notification settings - Fork 7.5k
73% smaller app bundle, 1.5x faster time-to-interactive using dynamic imports #16426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
catFurr
wants to merge
9
commits into
jitsi:master
Choose a base branch
from
alfaz-studio:fix-bundle-size
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+498
−176
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2703599
delay load zxcvbn/features_list
catFurr 7efe3a5
delay load excalidraw
catFurr 50a9e6e
delay load rnnoise
catFurr 81a32e6
delay load ts-ebml
catFurr 4ea6b97
manual chunking
catFurr b1ce1a9
fix lint
catFurr 4facfd8
add chunks to html
catFurr b78d59a
fix webpack
catFurr 44ed23d
fix native implementation
catFurr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { isEqual } from 'lodash-es'; | ||
| import { NIL, parse as parseUUID } from 'uuid'; | ||
|
|
||
| // The null UUID. | ||
| const NIL_UUID = parseUUID(NIL); | ||
|
|
||
| const _zxcvbnCache = new Map(); | ||
| let _zxcvbnPromise: Promise<any> | null = null; | ||
|
|
||
| /** | ||
| * Checks if the given string is a valid UUID or not. | ||
| * | ||
| * @param {string} str - The string to be checked. | ||
| * @returns {boolean} - Whether the string is a valid UUID or not. | ||
| */ | ||
| function isValidUUID(str: string) { | ||
| let uuid; | ||
|
|
||
| try { | ||
| uuid = parseUUID(str); | ||
| } catch (e) { | ||
| return false; | ||
| } | ||
|
|
||
| return !isEqual(uuid, NIL_UUID); | ||
| } | ||
|
|
||
| /** | ||
| * Dynamically imports zxcvbn library. | ||
| * | ||
| * @returns {Promise} - Promise that resolves to zxcvbn module. | ||
| */ | ||
| function _getZxcvbn() { | ||
| if (!_zxcvbnPromise) { | ||
| _zxcvbnPromise = import(/* webpackChunkName: "zxcvbn" */ 'zxcvbn').then(module => module.default); | ||
| } | ||
|
|
||
| return _zxcvbnPromise; | ||
| } | ||
|
|
||
| /** | ||
| * Checks a room name and caches the result. | ||
| * | ||
| * @param {string} roomName - The room name. | ||
| * @returns {Promise<Object>} - Promise that resolves to zxcvbn result. | ||
| */ | ||
| async function _checkRoomName(roomName = '') { | ||
| if (_zxcvbnCache.has(roomName)) { | ||
| return _zxcvbnCache.get(roomName); | ||
| } | ||
|
|
||
| const zxcvbn = await _getZxcvbn(); | ||
| const result = zxcvbn(roomName); | ||
|
|
||
| _zxcvbnCache.set(roomName, result); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if the room name is considered a weak (insecure) one. | ||
| * | ||
| * @param {string} roomName - The room name. | ||
| * @returns {Promise<boolean>} - Promise that resolves to boolean. | ||
| */ | ||
| export default async function isInsecureRoomName(roomName = ''): Promise<boolean> { | ||
| // room names longer than 200 chars we consider secure | ||
| if (isValidUUID(roomName) || roomName.length >= 200) { | ||
| return false; | ||
| } | ||
|
|
||
| const result = await _checkRoomName(roomName); | ||
|
|
||
| return result.score < 3; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { useEffect, useState } from 'react'; | ||
|
|
||
| import isInsecureRoomName from './isInsecureRoomName'; | ||
|
|
||
| /** | ||
| * Custom hook to check if a room name is insecure asynchronously. | ||
| * | ||
| * @param {string} roomName - The room name to check. | ||
| * @param {boolean} enabled - Whether the check should be performed. | ||
| * @returns {boolean} - Whether the room name is insecure. | ||
| */ | ||
| export default function useInsecureRoomName(roomName: string, enabled: boolean): boolean { | ||
| const [ isInsecure, setIsInsecure ] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| if (!enabled || !roomName) { | ||
| setIsInsecure(false); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| let isMounted = true; | ||
|
|
||
| isInsecureRoomName(roomName) | ||
| .then(result => { | ||
| if (isMounted) { | ||
| setIsInsecure(result); | ||
| } | ||
| }) | ||
| .catch(() => { | ||
| // If zxcvbn fails to load, assume room is secure | ||
| if (isMounted) { | ||
| setIsInsecure(false); | ||
| } | ||
| }); | ||
|
|
||
| return () => { | ||
| isMounted = false; | ||
| }; | ||
| }, [ roomName, enabled ]); | ||
|
|
||
| return isInsecure; | ||
| } |
58 changes: 0 additions & 58 deletions
58
react/features/conference/components/AbstractInsecureRoomNameLabel.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this defeat the purpose of bundling it out, if we are going to load it at the start all the same?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The react and vendor scripts are cached separately by the browser. So if we change our app code, browsers can reuse those (only app.bundle will be fetched).
We should only increment the
?vnumber for react and vendor if the package-lock.json file changes.Stuff like excalidraw and rnnoise are still lazy loaded when needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damencho Do you foresee a problem here? Any of our deployment scripts will need an update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well here at build time we put the jitsi-meet new version and on our deployments we always use base url. So that will be updated with the packages. I don't see a reason to handle it differently than the app bundle.
There is no point of following package-lock file, as that is always changed between stable versions and so on.