{"action":"created","issue":{"url":"https://api.github.com/repos/dozoisch/react-async-script/issues/6","labels_url":"https://api.github.com/repos/dozoisch/react-async-script/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/dozoisch/react-async-script/issues/6/comments","events_url":"https://api.github.com/repos/dozoisch/react-async-script/issues/6/events","html_url":"https://github.com/dozoisch/react-async-script/issues/6","id":113299079,"number":6,"title":"Intermittent \"Script is not loaded\" Error when using callbackName","user":{"login":"Schmicko","id":814227,"avatar_url":"https://avatars.githubusercontent.com/u/814227?v=3","gravatar_id":"","url":"https://api.github.com/users/Schmicko","html_url":"https://github.com/Schmicko","followers_url":"https://api.github.com/users/Schmicko/followers","following_url":"https://api.github.com/users/Schmicko/following{/other_user}","gists_url":"https://api.github.com/users/Schmicko/gists{/gist_id}","starred_url":"https://api.github.com/users/Schmicko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Schmicko/subscriptions","organizations_url":"https://api.github.com/users/Schmicko/orgs","repos_url":"https://api.github.com/users/Schmicko/repos","events_url":"https://api.github.com/users/Schmicko/events{/privacy}","received_events_url":"https://api.github.com/users/Schmicko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-26T07:21:06Z","updated_at":"2015-10-28T03:30:04Z","closed_at":null,"body":"Hey there,\r\n\r\nWe're getting this error intermittently when trying to load the GoogleMaps Api.\r\n\r\nIt looks like what's happening is that `asyncScriptLoaderTriggerOnScriptLoaded` is being called before the script `onLoad` event fires. Only happens about once in 5 refreshes.\r\n\r\nI have a workaround that feels kind of hacky. It just ignores `mapEntry.loaded` if `callbackName` is defined.\r\n\r\n``` javascript\r\n      asyncScriptLoaderTriggerOnScriptLoaded() {\r\n        let mapEntry = SCRIPT_MAP.get(scriptURL);\r\n        const { callbackName } = options;\r\n        if (!mapEntry || !mapEntry.loaded && !callbackName) {\r\n          throw new Error(\"Script is not loaded.\");\r\n        }\r\n```\r\n\r\nI'd be happy to help out with this. Not sure what the right direction to go is though.\r\n"},"comment":{"url":"https://api.github.com/repos/dozoisch/react-async-script/issues/comments/151711054","html_url":"https://github.com/dozoisch/react-async-script/issues/6#issuecomment-151711054","issue_url":"https://api.github.com/repos/dozoisch/react-async-script/issues/6","id":151711054,"user":{"login":"Schmicko","id":814227,"avatar_url":"https://avatars.githubusercontent.com/u/814227?v=3","gravatar_id":"","url":"https://api.github.com/users/Schmicko","html_url":"https://github.com/Schmicko","followers_url":"https://api.github.com/users/Schmicko/followers","following_url":"https://api.github.com/users/Schmicko/following{/other_user}","gists_url":"https://api.github.com/users/Schmicko/gists{/gist_id}","starred_url":"https://api.github.com/users/Schmicko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Schmicko/subscriptions","organizations_url":"https://api.github.com/users/Schmicko/orgs","repos_url":"https://api.github.com/users/Schmicko/repos","events_url":"https://api.github.com/users/Schmicko/events{/privacy}","received_events_url":"https://api.github.com/users/Schmicko/received_events","type":"User","site_admin":false},"created_at":"2015-10-28T03:30:04Z","updated_at":"2015-10-28T03:30:04Z","body":"Hey Hugo,\r\n\r\nSo, having slept on this for a couple of nights, I'm thinking the better way to handle this case is if the user has given a callbackName, to assume that this will actually be called and therefore not listen to the onload event in the first place. The onerror event still makes sense though.\r\n\r\nI'm going to see if I can get that to work.\r\n"}}