Last active
January 9, 2021 02:28
-
-
Save milksense/d2798bc4a4cc54bd9180582377161b84 to your computer and use it in GitHub Desktop.
Conditional Import
This file contains 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
/** | |
* Conditional Import example | |
* | |
* @return {(Promise|NULL)} Expected result | |
* @see {@link https://css-tricks.com/responsible-conditional-loading/} for further information. | |
*/ | |
(async () => { | |
if (navigator.connection.saveData === false) { | |
const { v4: uuidv4 } = await import( | |
"https://cdn.skypack.dev/uuid" | |
); | |
console.log(uuidv4()) | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment