{"action":"created","issue":{"url":"https://api.github.com/repos/josdejong/mathjs/issues/766","repository_url":"https://api.github.com/repos/josdejong/mathjs","labels_url":"https://api.github.com/repos/josdejong/mathjs/issues/766/labels{/name}","comments_url":"https://api.github.com/repos/josdejong/mathjs/issues/766/comments","events_url":"https://api.github.com/repos/josdejong/mathjs/issues/766/events","html_url":"https://github.com/josdejong/mathjs/issues/766","id":197397083,"number":766,"title":"Unused library functions","user":{"login":"hcvazquez","id":16074870,"avatar_url":"https://avatars.githubusercontent.com/u/16074870?v=3","gravatar_id":"","url":"https://api.github.com/users/hcvazquez","html_url":"https://github.com/hcvazquez","followers_url":"https://api.github.com/users/hcvazquez/followers","following_url":"https://api.github.com/users/hcvazquez/following{/other_user}","gists_url":"https://api.github.com/users/hcvazquez/gists{/gist_id}","starred_url":"https://api.github.com/users/hcvazquez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hcvazquez/subscriptions","organizations_url":"https://api.github.com/users/hcvazquez/orgs","repos_url":"https://api.github.com/users/hcvazquez/repos","events_url":"https://api.github.com/users/hcvazquez/events{/privacy}","received_events_url":"https://api.github.com/users/hcvazquez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-23T16:35:13Z","updated_at":"2016-12-24T09:30:30Z","closed_at":null,"body":"My name is Hernan; with a group of colleagues we are conducting a research about unused code present in dependencies of JavaScript projects. We call this functions, UFF (Unused foreign functions). We found that in most projects there exist a great amount of UFF that are being included in the final bundle. \r\n \r\nIn the case of mathjs (v 3.5.1) our tools detected approximately 72 unused function in the dependencies. Removing those functions, the size of mathjs bundled could be reduced at least 2% (All tests passed). I replaced the bundled in several projects that use mathjs as loess, dn2a, dext and pullquoter. I’m attaching the reduced version of your project. \r\n[math(optimized).txt](https://github.com/josdejong/mathjs/files/671126/math.optimized.txt)\r\n\r\n \r\nI’ll be very grateful if you can answer me the following questions:\r\n-Did you were aware of the existence of these unused functions in your projects?\r\n-Do you think that this is a problem? \r\n-Do you think that can be useful a tool for deal with this kind of problem?\r\n\r\nThanks in advance.\r\n\r\nCheers,"},"comment":{"url":"https://api.github.com/repos/josdejong/mathjs/issues/comments/269076910","html_url":"https://github.com/josdejong/mathjs/issues/766#issuecomment-269076910","issue_url":"https://api.github.com/repos/josdejong/mathjs/issues/766","id":269076910,"user":{"login":"josdejong","id":568626,"avatar_url":"https://avatars.githubusercontent.com/u/568626?v=3","gravatar_id":"","url":"https://api.github.com/users/josdejong","html_url":"https://github.com/josdejong","followers_url":"https://api.github.com/users/josdejong/followers","following_url":"https://api.github.com/users/josdejong/following{/other_user}","gists_url":"https://api.github.com/users/josdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/josdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josdejong/subscriptions","organizations_url":"https://api.github.com/users/josdejong/orgs","repos_url":"https://api.github.com/users/josdejong/repos","events_url":"https://api.github.com/users/josdejong/events{/privacy}","received_events_url":"https://api.github.com/users/josdejong/received_events","type":"User","site_admin":false},"created_at":"2016-12-24T09:30:30Z","updated_at":"2016-12-24T09:30:30Z","body":"Thanks Hernan. Unused code is in libraries indeed a serious problem. I think that projects using math.js typically only use a small portion, not 98% of it. But it's not so trivial to extract only the used parts. There is a difficulty here that math.js implements all functions for various data types (number, BigNumber, Matrix, Complex, Unit). If you would know beforehand that you want to use only numbers, it would be great if we could automatically strip all matrix related code from the library. That would yield a huge reduction in bundle size.\r\n\r\nI see you've stripped these 72 functions from the non-minified version (dist/math.js). Do these 72 functions also exist in the minified version (dist/math.min.js)? If I'm not mistaken the minifier automatically removes dead code.\r\n\r\nMore and more libraries make use of [tree shaking](https://blog.engineyard.com/2016/tree-shaking) by a bundler. I would love to enable that too for math.js, but that's not so easy because of the aforementioned reasons. You can create [custom bundles](http://mathjs.org/docs/custom_bundling.html), but it's much better when this would be done automatically by our bundlers (like dead code is removed automatically by minifiers).  See #71."}}
{"actor":{"display_login":"josdejong"}}