{"action":"created","issue":{"url":"https://api.github.com/repos/headjs/headjs/issues/330","labels_url":"https://api.github.com/repos/headjs/headjs/issues/330/labels{/name}","comments_url":"https://api.github.com/repos/headjs/headjs/issues/330/comments","events_url":"https://api.github.com/repos/headjs/headjs/issues/330/events","html_url":"https://github.com/headjs/headjs/issues/330","id":65226640,"number":330,"title":"head.ready('<label>') firing before script being loaded if taking too long","user":{"login":"monojp","id":5738896,"avatar_url":"https://avatars.githubusercontent.com/u/5738896?v=3","gravatar_id":"","url":"https://api.github.com/users/monojp","html_url":"https://github.com/monojp","followers_url":"https://api.github.com/users/monojp/followers","following_url":"https://api.github.com/users/monojp/following{/other_user}","gists_url":"https://api.github.com/users/monojp/gists{/gist_id}","starred_url":"https://api.github.com/users/monojp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monojp/subscriptions","organizations_url":"https://api.github.com/users/monojp/orgs","repos_url":"https://api.github.com/users/monojp/repos","events_url":"https://api.github.com/users/monojp/events{/privacy}","received_events_url":"https://api.github.com/users/monojp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-30T14:36:06Z","updated_at":"2015-03-30T15:23:29Z","closed_at":null,"body":"I've noticed that head.ready seems to fire the \"loaded\"-event although the script with the specified label hasn't even loaded fully. This is especially impacting slow connections and big scripts like e.g. jQuery. In my opinion there seems to be something fundamentally broken in head.js\r\n\r\nI've made a proof of concept on\r\n\r\nhttp://playground.herndl.org/\r\n\r\n```php\r\n<?php\r\n\r\nif (isset($_GET['js'])) {\r\n\t$js = $_GET['js'];\r\n\r\n\theader('Content-Type: text/javascript');\r\n\r\n\tif ($js == 'fast')\r\n\t\techo 'debug(\"loaded script \\'fast\\'\");';\r\n\telse if ($js == 'slow') {\r\n\t\tsleep(10);\r\n\t\techo 'debug(\"loaded script \\'slow\\'\");';\r\n\t}\r\n\texit;\r\n}\r\n\r\n?>\r\n<!DOCTYPE html>\r\n<html>\r\n<head>\r\n\t<title><?php echo $_SERVER['SERVER_NAME']; ?></title>\r\n\t<meta charset=UTF-8>\r\n\t<script type=\"text/javascript\" src=\"head.min.js\"></script>\r\n</head>\r\n<body>\r\n\t<pre id=\"output\"></pre>\r\n\t<script type=\"text/javascript\">\r\n\t\tfunction debug(text) {\r\n\t\t\t//console.log(text); // this does not work in old IE\r\n\t\t\tdocument.getElementById('output').innerHTML += '<br>' + text;\r\n\t\t}\r\n\t\thead.ready('fast', function() {\r\n\t\t\tdebug(\"'fast' ready event fired\");\r\n\t\t});\r\n\t\thead.ready('slow', function() {\r\n\t\t\tdebug(\"'slow' ready event fired\");\r\n\t\t});\r\n\r\n\t\tdebug(\"start loading script 'fast' and 'slow'\");\r\n\t\thead.load({fast: '?js=fast'}, {slow: '?js=slow'});\r\n\t</script>\r\n</body>\r\n</html>\r\n```\r\n\r\nIt outputs\r\n\r\n> start loading script 'fast' and 'slow'\r\n> loaded script 'fast'\r\n> 'fast' ready event fired\r\n> 'slow' ready event fired\r\n> loaded script 'slow'\r\n\r\nI would love to see this getting fixed as well as the other open issues here on github, but the project seems to be dead?"},"comment":{"url":"https://api.github.com/repos/headjs/headjs/issues/comments/87721650","html_url":"https://github.com/headjs/headjs/issues/330#issuecomment-87721650","issue_url":"https://api.github.com/repos/headjs/headjs/issues/330","id":87721650,"user":{"login":"monojp","id":5738896,"avatar_url":"https://avatars.githubusercontent.com/u/5738896?v=3","gravatar_id":"","url":"https://api.github.com/users/monojp","html_url":"https://github.com/monojp","followers_url":"https://api.github.com/users/monojp/followers","following_url":"https://api.github.com/users/monojp/following{/other_user}","gists_url":"https://api.github.com/users/monojp/gists{/gist_id}","starred_url":"https://api.github.com/users/monojp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monojp/subscriptions","organizations_url":"https://api.github.com/users/monojp/orgs","repos_url":"https://api.github.com/users/monojp/repos","events_url":"https://api.github.com/users/monojp/events{/privacy}","received_events_url":"https://api.github.com/users/monojp/received_events","type":"User","site_admin":false},"created_at":"2015-03-30T15:23:29Z","updated_at":"2015-03-30T15:23:29Z","body":"I wrote the developer on his G+ page. Let's wait and see :smile: \r\nfyi the bug I mentioned seemed to occur on chrom(e|ium) and firefox, but not IE7 for example. I am still testing around"}}