{"action":"created","issue":{"url":"https://api.github.com/repos/OCTRI/REDCap-Vizr/issues/51","repository_url":"https://api.github.com/repos/OCTRI/REDCap-Vizr","labels_url":"https://api.github.com/repos/OCTRI/REDCap-Vizr/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/OCTRI/REDCap-Vizr/issues/51/comments","events_url":"https://api.github.com/repos/OCTRI/REDCap-Vizr/issues/51/events","html_url":"https://github.com/OCTRI/REDCap-Vizr/issues/51","id":340840439,"node_id":"MDU6SXNzdWUzNDA4NDA0Mzk=","number":51,"title":"Optimize or Replace Moment.js","user":{"login":"heathharrelson","id":2746306,"node_id":"MDQ6VXNlcjI3NDYzMDY=","avatar_url":"https://avatars1.githubusercontent.com/u/2746306?v=4","gravatar_id":"","url":"https://api.github.com/users/heathharrelson","html_url":"https://github.com/heathharrelson","followers_url":"https://api.github.com/users/heathharrelson/followers","following_url":"https://api.github.com/users/heathharrelson/following{/other_user}","gists_url":"https://api.github.com/users/heathharrelson/gists{/gist_id}","starred_url":"https://api.github.com/users/heathharrelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heathharrelson/subscriptions","organizations_url":"https://api.github.com/users/heathharrelson/orgs","repos_url":"https://api.github.com/users/heathharrelson/repos","events_url":"https://api.github.com/users/heathharrelson/events{/privacy}","received_events_url":"https://api.github.com/users/heathharrelson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-13T00:20:50Z","updated_at":"2018-07-13T17:49:09Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"While doing some profiling with [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer), I noticed that Moment.js is a significant fraction of our bundle size, largely because all of the locales are included:\r\n\r\n| State | Total Bundle | Moment.js | Percentage |\r\n| --- | --- | --- | --- |\r\n| Uncompressed | 2099.2 KB | 528.35 KB | ~25% |\r\n| Compressed | 458.31 KB | 92.81 KB | ~20%|\r\n\r\nEven worse, Moment.js is bundled in Chart.js, so we take the hit *twice*.\r\n\r\nNeither our code, nor the code in Chart.js uses Moment's locales, so we could just strip them out of the bundle using Webpack:\r\n\r\nhttps://github.com/jmblog/how-to-optimize-momentjs-with-webpack\r\n\r\nChart.js comes in two releases: [a version with Moment.js bundled in](https://www.chartjs.org/docs/latest/getting-started/installation.html#bundled-build) (what we're using now), and a [standalone release](https://www.chartjs.org/docs/latest/getting-started/installation.html#stand-alone-build) that doesn't include Moment. Because Vizr doesn't use the time axis type (it constructs date strings for the axis), we may be able to simply switch to the standalone release.\r\n\r\nAs for Vizr itself, we might be able to replace Moment.js with [Luxon](https://moment.github.io/luxon/), which has a similar API but supports tree-shaking for smaller build sizes.\r\n"},"comment":{"url":"https://api.github.com/repos/OCTRI/REDCap-Vizr/issues/comments/404905511","html_url":"https://github.com/OCTRI/REDCap-Vizr/issues/51#issuecomment-404905511","issue_url":"https://api.github.com/repos/OCTRI/REDCap-Vizr/issues/51","id":404905511,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDkwNTUxMQ==","user":{"login":"heathharrelson","id":2746306,"node_id":"MDQ6VXNlcjI3NDYzMDY=","avatar_url":"https://avatars1.githubusercontent.com/u/2746306?v=4","gravatar_id":"","url":"https://api.github.com/users/heathharrelson","html_url":"https://github.com/heathharrelson","followers_url":"https://api.github.com/users/heathharrelson/followers","following_url":"https://api.github.com/users/heathharrelson/following{/other_user}","gists_url":"https://api.github.com/users/heathharrelson/gists{/gist_id}","starred_url":"https://api.github.com/users/heathharrelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heathharrelson/subscriptions","organizations_url":"https://api.github.com/users/heathharrelson/orgs","repos_url":"https://api.github.com/users/heathharrelson/repos","events_url":"https://api.github.com/users/heathharrelson/events{/privacy}","received_events_url":"https://api.github.com/users/heathharrelson/received_events","type":"User","site_admin":false},"created_at":"2018-07-13T17:49:09Z","updated_at":"2018-07-13T17:49:09Z","author_association":"CONTRIBUTOR","body":"In PR #53 I reconfigured Vizr to import the standalone version of Chart.js, which has eliminated the second copy of Moment.js. It's probably worth doing an experiment with Luxon to see what improvements we can get."}}
{"actor":{"display_login":"heathharrelson"}}