Skip to content

Conditional loading #1

Description

@dmitrizzle

Do you think it's possible to load polyfills conditionally, as in:

if (
        'startsWith' in String.prototype &&
        'endsWith' in String.prototype &&
        'includes' in Array.prototype &&
        'assign' in Object &&
        'keys' in Object
    )
        // avoid punishing modern browser users
        return;

import("core-js/...")

The trick being that all of Next.js scripts would have to wait for this step to complete (either skipping polyfill loads or waiting for core-js imports to complete.

This was easy to do without Next, however, now it seems quite tricky.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions