Skip to content
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

Add ability to lazy load each component individually #745

Open
axelthat opened this issue Oct 2, 2024 · 1 comment
Open

Add ability to lazy load each component individually #745

axelthat opened this issue Oct 2, 2024 · 1 comment

Comments

@axelthat
Copy link

axelthat commented Oct 2, 2024

Is your feature request related to a problem? Please describe.
File Uploader is a huge component for someone that only wants to use the minimal uploader with minimal functionalities. Thus, being able to lazy load each component individually would boost the initial page load performance by a lot.

Describe the solution you'd like
Add ability to lazy load each component individually

Describe alternatives you've considered
No alternatives but would love to do something like this:

await Promise.all([
    import('@uploadcare/file-uploader/abstract/defineComponents'),
    import('@uploadcare/file-uploader/blocks/FileUploaderMinimal/FileUploaderMinimal'),
    import('@uploadcare/file-uploader/blocks/BaseComponent/BaseComponent'),
    import('@uploadcare/file-uploader/blocks/DropArea/DropArea'),
    import('@uploadcare/file-uploader/blocks/Config/Config'),
    import('@uploadcare/file-uploader/blocks/Copyright/Copyright'),
    import('@uploadcare/file-uploader/blocks/UploadList/UploadList'),
    import('@uploadcare/file-uploader/blocks/ActivityHeader/ActivityHeader'),
    import('@uploadcare/file-uploader/blocks/StartFrom/StartFrom'),
    import('@uploadcare/file-uploader/blocks/Icon/Icon'),
    import('@uploadcare/file-uploader/blocks/FileItem/FileItem'),
    import('@uploadcare/file-uploader/blocks/ProgressBar/ProgressBar')
])
@axelthat axelthat changed the title Add ability to import each component individually Add ability to lazy load each component individually Oct 2, 2024
@nd0ut
Copy link
Member

nd0ut commented Oct 2, 2024

Hey @axelthat,

This might not be exactly what you're looking for, but you can import a prebuilt minimal uploader bundle like this:

import * as UC from "@uploadcare/file-uploader/web/uc-file-uploader-minimal.min.js";
import "@uploadcare/file-uploader/web/uc-file-uploader-minimal.min.css";

UC.defineComponents(UC);

It's about 30kb smaller (gzip) than the full bundle, including CSS.

As for lazy loading, we’ve been considering lazy-loading specific parts of the uploader, like the Cloud Image Editor. It’s pretty big and can even be disabled in the regular mode, but it’s not on the roadmap yet, so no ETA for now.

Also, if you're using a modern framework with support for component lazy loading, feel free to use it.

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

No branches or pull requests

2 participants