daru-view
daru-view copied to clipboard
Reduce the size of the gem
We can see the gem size here : https://rubygems.org/gems/daru-view
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 ?
It should download the js, css files to vendor/assests/ folder
while installing the gem. It will reduce the size.
Hi @Shekharrajak, I would like to fix this issue but need some guidance. Thanks.
@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).
So , I need to remove the googlecharts js , css files and leave the highcharts js, css files as it is?
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).
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?
You must try it and check if any testcase is failing. I hope you have gone through development workflow.
Yes I have checked that, the testsuits are running the same after regenerating those js files, without throwing any error with respect to googlecharts.
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?
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.
Please let me know what are steps you followed.
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?
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.
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.