Coder Social home page Coder Social logo

Comments (12)

FrancescoCioria avatar FrancescoCioria commented on July 30, 2024

The npm package is compiled in JavaScript 5, you can simply import it in your project and create a bundle using browserify or webpack. About the UI I haven't tested IE yet, so I can't guarantee it will work correctly. I'll verify it in the following days

from rc-datepicker.

luokuning avatar luokuning commented on July 30, 2024

So much clear ! Thanks a lot ~

from rc-datepicker.

luokuning avatar luokuning commented on July 30, 2024

I install the datepicker via npm, and create a bundle.js using Browserify, but I found a new problem: bundle.js is closeto 1000KB, it is too heavyweight in browser. Is there any way to make it lighter?

from rc-datepicker.

FrancescoCioria avatar FrancescoCioria commented on July 30, 2024

bundle.js is a big JavaScript file with everything you need inside so to reduce its size you can proceed as always: first minify it and then gzip it. (by using a plugin of gulp/grunt/webpack or here: minify gzip)

from rc-datepicker.

gabro avatar gabro commented on July 30, 2024

Does bundle.js include all the locale files?

from rc-datepicker.

FrancescoCioria avatar FrancescoCioria commented on July 30, 2024

@luokuning I think I misunderstood your question before. The bundle.js you're referring to probably contains other libraries (like ReactJS) that's why Its size is around 1mb. Our datepicker, if minified, should be around ~40/50kb which would decrease even more if gzipped. The biggest part of its size comes from Moment.js which minified is about ~34kb.

from rc-datepicker.

luokuning avatar luokuning commented on July 30, 2024

@FrancescoCioria I realized that I have missing something on Browserify.First time I packed the DatePicker.js by the following code:

browserify DatePicker.js > DatePicker_browser.js

and then the size of DatePicker_browser.js is nearly 1000KB. Then I checked the Browserify home page and found that if there is no need to include some file I should use the ' --ignore' param, so my code become follows:

browserify DatePicker.js --ignore react/addons --ignore/react --ignore moment > DatePicker_browser.js

And the file become lighter as expected, but it still approaching 130KB. Am I still missing something in Browserify or anything else?

from rc-datepicker.

luokuning avatar luokuning commented on July 30, 2024

@gabro Yes, I think so, as Browserify will pack all files needed into one file.

from rc-datepicker.

gabro avatar gabro commented on July 30, 2024

What browserify does is to recursively include in the bundle every require it finds and that's what you want in the end: in your final project you're probably shipping a whole react application so it makes sense to include the reactjs library in your app bundle (unless you're bundling it separately, but that's another story)

So the idea is that somewhere in your react application you do

require("rc-datepicker")

and that causes the datepicker to be included by browserify into the final bundle.

So I guess the real question is: what do you need DatePicker_browser.js for? If you need it to work independently in a non-reactjs application, you'll need to include reactjs in it.
If you're using it in a reactjs application, then just use browserify and reactjs will get included only once in your app's bundle.

from rc-datepicker.

luokuning avatar luokuning commented on July 30, 2024

@gabro Yes, I have loaded react.js before, so I want to pack DatePicker.js > DatePicker_browser.js without reactjs, and use it later as a UI component. I understand what you mean is I should require("rc-datepicker") in where the component suppose to be implemented, such as in HomePage.js, and then use Browserify to pack HomePage.js?

from rc-datepicker.

gabro avatar gabro commented on July 30, 2024

Precisely.
rc-datepicker simply uses require to bring reactjs in, so if you have

HomePage.js -> DatePicker.js -> react
            \-> react

where the arrow means "requires", you can just run browserify on HomePage.js and it will produce a bundle containing HomePage.js, DatePicker.js and react (only once)

This is exactly why we distribute the source, rather than a standalone minified build. This way you can build and optimize your app as you prefer, using any build system (wepack, browserify, you name it!)

from rc-datepicker.

luokuning avatar luokuning commented on July 30, 2024

So it is, I got you! Thanks you guys for creating a awesome datetimepicker component, and helping to solve my puzzles! 😄

from rc-datepicker.

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.