SciRuby / daru-view

daru-view is for easy and interactive plotting in web application & IRuby notebook. daru-view is a plugin gem to the existing daru gem.
https://sciruby.github.io/daru-view/
MIT License
95 stars 20 forks source link

Reduce the size of the gem #127

Open Shekharrajak opened 5 years ago

Shekharrajak commented 5 years ago

We can see the gem size here : https://rubygems.org/gems/daru-view

image

Looks like our dummy_iruby notebook examples and js files increasing the gem size.But

Is there anything else that causes, this much size ?

Shekharrajak commented 5 years ago

It should download the js, css files to vendor/assests/ folder while installing the gem. It will reduce the size.

snpd25 commented 5 years ago

Hi @Shekharrajak, I would like to fix this issue but need some guidance. Thanks.

Shekharrajak commented 5 years ago

@snpd25 , first step will be , to find out the files and folders which can be removed from the gem source . You can see there are many js ,css files present in the vendor/assets folder , so that highcharts can work offline as well. (I think we can remove the googlecharts js files , since any way it requrie internet - You can find out more about it in blog or wiki page).

Now we have only highcharts js , css files. We want daru-view highcharts library working without internet as well, so we need it (after or while the installation). Since we can update the js and css file : https://github.com/SciRuby/daru-view/pull/83 . Similarly we need to download it if internet is available (or it should be present already while the installation - may be compressed).

snpd25 commented 5 years ago

So , I need to remove the googlecharts js , css files and leave the highcharts js, css files as it is?

Shekharrajak commented 5 years ago

See how daru-view googlechart adapter is using those js files and what will be the impact when you remove it (understand how it will work without those files - by running IRuby notebook examples present in spec/dummy_iruby).

You can create a PR so that I can understand your approach (I just want to see other approaches, so I have just given a hint).

snpd25 commented 5 years ago

I guess many unnecessary files are already removed, presently there are 3 files : jspdf.min.js , loader.js and google_visualr.js . The command daru-view update --googlecharts can generate jspdf.min.js and loader.js .So should I remove them?

Shekharrajak commented 5 years ago

You must try it and check if any testcase is failing. I hope you have gone through development workflow.

snpd25 commented 5 years ago

Yes I have checked that, the testsuits are running the same after regenerating those js files, without throwing any error with respect to googlecharts.

Shekharrajak commented 5 years ago

Yes, that is for developers. In the user perspective, the gem will not be having those files. Without running any command how it will plot graphs?

snpd25 commented 5 years ago

I think I haven't understood about the files you are referring to. As I have checked, from the user perspective as well, those three js files of googlecharts are present.

Shekharrajak commented 5 years ago

Please let me know what are steps you followed.

snpd25 commented 5 years ago

I ran the test-suite using bundle exec rspec then I removed the js files and regenerated them using daru-view update --googlecharts and then I ran the test-suite, which showed no changes except when I removed the file google_visualr.js . Was I required to do something else?

Shekharrajak commented 5 years ago

Can you figure it out where daru-view gem will be installed when a user run gem install daru-view in the system?

Can you remove these JS files and build a local gem using gem build daru-view.gemspec and installed in your system?

So users should not run any command after the installation right? Gem should be able to handle this task automatically when the internet is available (what should it do when the internet is not available while installing the gem? Can it generate the charts without internet as well - may be we can do some changes in our code and rather than loading the js file we can use script tag provided the link)

I removed the js files

It seems you deleted the js files of your cloned repo folder.

snpd25 commented 5 years ago

The gem will be found in /home/user/.rvm/gems/ruby-2.4.1/gems/daru-view-0.2.4. It can't generate those js files without the internet. I tried building a local gem but it threw error, due to the absence of those files. Either I will have to edit the gem specifications or these files are too necessary to be removed.