Code Monkey home page Code Monkey logo

Comments (9)

huumn avatar huumn commented on July 22, 2024

We used to do this. It made the bundle size HUGE for not much gain. It can probably be done efficiently with selective, dynamic imports.

A solution should use https://nextjs.org/docs/app/building-your-application/optimizing/bundle-analyzer to make sure it doesn't bloat the bundle.

from stacker.news.

tsmith123 avatar tsmith123 commented on July 22, 2024

How about just importing the files for a few popular languages to tackle this one? If so, which languages would you want to support?

from stacker.news.

huumn avatar huumn commented on July 22, 2024

If they’re dynamically imported, it shouldn’t matter how many we support. But maybe we can find the top 5 somewhere

from stacker.news.

tsmith123 avatar tsmith123 commented on July 22, 2024

I'm not sure how you'd decide when to "dynamically import" a language file. Selectively importing languages on build would keep the size down but you'd be limited those that you choose. If you mean importing them on the fly then that's a whole different ball game.

from stacker.news.

huumn avatar huumn commented on July 22, 2024

If you mean importing them on the fly then that's a whole different ball game.

That's the ball game I mean.

Unless we use dynamic imports, this isn't worth the bundle size bloat. Maybe we can dynamically import all languages. It's been a long time since I've looked at the code, but I think each language can be imported only when they're used.

from stacker.news.

tsmith123 avatar tsmith123 commented on July 22, 2024

Well there is such a thing as dynamic imports but that isn't what you refer to as dynamic imports. You can choose which languages you want ahead of time but not during runtime.

from stacker.news.

huumn avatar huumn commented on July 22, 2024

https://mieszkogulinski.github.io/next-js-conditional-dynamic-import/

from stacker.news.

tsmith123 avatar tsmith123 commented on July 22, 2024

That's cool but once you've imported how do you decide when to drop it or does it just "exist" for the duration of the page view?

from stacker.news.

huumn avatar huumn commented on July 22, 2024

You don't decide to drop it. The browser caches it or doesn't. The main thing is that it's only downloaded if it's used.

from stacker.news.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.