daru-view icon indicating copy to clipboard operation
daru-view copied to clipboard

Reduce the size of the gem

Open Shekharrajak opened this issue 6 years ago • 14 comments

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

  • we should have all the features demo in iruby notebook.
  • we should have dependent js files present in source code, so that it can work offline.

Is there anything else that causes, this much size ?

Shekharrajak avatar Dec 06 '18 08:12 Shekharrajak

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

Shekharrajak avatar Dec 06 '18 10:12 Shekharrajak

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

snpd25 avatar Jan 19 '19 17:01 snpd25

@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).

Shekharrajak avatar Jan 19 '19 22:01 Shekharrajak

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

snpd25 avatar Jan 20 '19 12:01 snpd25

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).

Shekharrajak avatar Jan 20 '19 13:01 Shekharrajak

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?

snpd25 avatar Jan 20 '19 20:01 snpd25

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

Shekharrajak avatar Jan 21 '19 04:01 Shekharrajak

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

snpd25 avatar Jan 21 '19 13:01 snpd25

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?

Shekharrajak avatar Jan 24 '19 06:01 Shekharrajak

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.

snpd25 avatar Jan 26 '19 06:01 snpd25

Please let me know what are steps you followed.

Shekharrajak avatar Jan 26 '19 07:01 Shekharrajak

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?

snpd25 avatar Jan 26 '19 08:01 snpd25

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.

Shekharrajak avatar Jan 26 '19 14:01 Shekharrajak

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.

snpd25 avatar Jan 27 '19 10:01 snpd25