{"action":"created","issue":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/888","labels_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/888/labels{/name}","comments_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/888/comments","events_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/888/events","html_url":"https://github.com/elm-lang/elm-compiler/issues/888","id":55607378,"number":888,"title":"Memoize module make functions in the embedded scenario","user":{"login":"rehno-lindeque","id":337811,"avatar_url":"https://avatars.githubusercontent.com/u/337811?v=3","gravatar_id":"","url":"https://api.github.com/users/rehno-lindeque","html_url":"https://github.com/rehno-lindeque","followers_url":"https://api.github.com/users/rehno-lindeque/followers","following_url":"https://api.github.com/users/rehno-lindeque/following{/other_user}","gists_url":"https://api.github.com/users/rehno-lindeque/gists{/gist_id}","starred_url":"https://api.github.com/users/rehno-lindeque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rehno-lindeque/subscriptions","organizations_url":"https://api.github.com/users/rehno-lindeque/orgs","repos_url":"https://api.github.com/users/rehno-lindeque/repos","events_url":"https://api.github.com/users/rehno-lindeque/events{/privacy}","received_events_url":"https://api.github.com/users/rehno-lindeque/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-27T11:41:25Z","updated_at":"2015-01-27T14:57:47Z","closed_at":null,"body":"I've been investigating the loading for our elm widgets...\r\n\r\nIt appears to me that when several widgets are instantiated (embedded), repeated calls to `make` for a large module is very slow. In particular, [Bootstrap.Html](http://package.elm-lang.org/packages/circuithub/elm-bootstrap-html/4.0.0/Bootstrap-Html)`.make()` takes a large amount of time:\r\n\r\n![timeline](https://cloud.githubusercontent.com/assets/337811/5917625/a0cacaf2-a627-11e4-86c3-d4ef39928a2a.png)\r\n\r\nOne way of testing this quickly is as follows:\r\n```javascript\r\nfor (var i = 0; i < 100; ++i) {\r\n    Elm.Bootstrap.Html.make({});\r\n}\r\n```\r\nThe above takes 12.68s on my laptop.\r\n\r\nOne quick solution might be to memoize the `make` function. The generated function currently looks like this...\r\n```javascript\r\nElm.Bootstrap.Html.make = function (_elm) { ... }\r\n```\r\n...I'm not sure if it would be necessary to memoize the function based on the incoming `_elm` RTS, but it seems like that shouldn't be necessary. One edge case is if someone is uses different versions of the same package for different embedded widgets (although, in this case they will have to have different compiled `.js` files for each widget, so these could be independently memoized).\r\n"},"comment":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/comments/71660784","html_url":"https://github.com/elm-lang/elm-compiler/issues/888#issuecomment-71660784","issue_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/888","id":71660784,"user":{"login":"evancz","id":1658058,"avatar_url":"https://avatars.githubusercontent.com/u/1658058?v=3","gravatar_id":"","url":"https://api.github.com/users/evancz","html_url":"https://github.com/evancz","followers_url":"https://api.github.com/users/evancz/followers","following_url":"https://api.github.com/users/evancz/following{/other_user}","gists_url":"https://api.github.com/users/evancz/gists{/gist_id}","starred_url":"https://api.github.com/users/evancz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evancz/subscriptions","organizations_url":"https://api.github.com/users/evancz/orgs","repos_url":"https://api.github.com/users/evancz/repos","events_url":"https://api.github.com/users/evancz/events{/privacy}","received_events_url":"https://api.github.com/users/evancz/received_events","type":"User","site_admin":false},"created_at":"2015-01-27T14:57:47Z","updated_at":"2015-01-27T14:57:47Z","body":"Makes sense. If it's possible to figure out how to do it in a safe way, I think it makes sense to do this in code generation. I can't focus on this right now, so it may be a good topic to discuss on elm-dev."}}