{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/10172","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/10172/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/10172/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/10172/events","html_url":"https://github.com/yiisoft/yii2/issues/10172","id":117317835,"number":10172,"title":"View::registerJsFile() registers the same file multiple times","user":{"login":"PowerGamer1","id":8275897,"avatar_url":"https://avatars.githubusercontent.com/u/8275897?v=3","gravatar_id":"","url":"https://api.github.com/users/PowerGamer1","html_url":"https://github.com/PowerGamer1","followers_url":"https://api.github.com/users/PowerGamer1/followers","following_url":"https://api.github.com/users/PowerGamer1/following{/other_user}","gists_url":"https://api.github.com/users/PowerGamer1/gists{/gist_id}","starred_url":"https://api.github.com/users/PowerGamer1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PowerGamer1/subscriptions","organizations_url":"https://api.github.com/users/PowerGamer1/orgs","repos_url":"https://api.github.com/users/PowerGamer1/repos","events_url":"https://api.github.com/users/PowerGamer1/events{/privacy}","received_events_url":"https://api.github.com/users/PowerGamer1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-17T09:43:46Z","updated_at":"2015-11-17T09:52:58Z","closed_at":null,"body":"As per `\\yii\\web\\View::registerJsFile()` documentation:\r\n```\r\n     * @param string $key the key that identifies the JS script file. If null, it will use\r\n     * $url as the key. If two JS files are registered with the same key, the latter\r\n     * will overwrite the former.\r\n```\r\nThe following code behaves correctly (as per documentation) - the file 1.js is registered only once:\r\n```\r\n$view->registerJsFile('c:\\dir\\1.js', ['position' => \\yii\\web\\View::POS_HEAD, 'depends' => [\\frontend\\assets\\AppAsset::className()]]);\r\n$view->registerJsFile('c:\\dir\\1.js', ['position' => \\yii\\web\\View::POS_END, 'depends' => [\\frontend\\assets\\AppAsset::className()]]);\r\n```\r\nThe following code behaves incorrectly - the file 1.js is registered twice in the HTML document:\r\n```\r\n$view->registerJsFile('c:\\dir\\1.js', ['position' => \\yii\\web\\View::POS_HEAD]);\r\n$view->registerJsFile('c:\\dir\\1.js', ['position' => \\yii\\web\\View::POS_END]);\r\n```"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/157323346","html_url":"https://github.com/yiisoft/yii2/issues/10172#issuecomment-157323346","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/10172","id":157323346,"user":{"login":"Alex-Code","id":1797626,"avatar_url":"https://avatars.githubusercontent.com/u/1797626?v=3","gravatar_id":"","url":"https://api.github.com/users/Alex-Code","html_url":"https://github.com/Alex-Code","followers_url":"https://api.github.com/users/Alex-Code/followers","following_url":"https://api.github.com/users/Alex-Code/following{/other_user}","gists_url":"https://api.github.com/users/Alex-Code/gists{/gist_id}","starred_url":"https://api.github.com/users/Alex-Code/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alex-Code/subscriptions","organizations_url":"https://api.github.com/users/Alex-Code/orgs","repos_url":"https://api.github.com/users/Alex-Code/repos","events_url":"https://api.github.com/users/Alex-Code/events{/privacy}","received_events_url":"https://api.github.com/users/Alex-Code/received_events","type":"User","site_admin":false},"created_at":"2015-11-17T09:52:58Z","updated_at":"2015-11-17T09:52:58Z","body":"The internal array is indexed by the position first so having having `POS_HEAD` and `POS_END` would allow this.\r\n\r\nWhy are you registering the same script in different positions anyway?"}}