Skip to content

Instantly share code, notes, and snippets.

@milksense
Last active January 9, 2021 02:28
Show Gist options
  • Save milksense/d2798bc4a4cc54bd9180582377161b84 to your computer and use it in GitHub Desktop.
Save milksense/d2798bc4a4cc54bd9180582377161b84 to your computer and use it in GitHub Desktop.
Conditional Import
/**
* 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