{"action":"created","issue":{"url":"https://api.github.com/repos/jquery/jquery/issues/1449","labels_url":"https://api.github.com/repos/jquery/jquery/issues/1449/labels{/name}","comments_url":"https://api.github.com/repos/jquery/jquery/issues/1449/comments","events_url":"https://api.github.com/repos/jquery/jquery/issues/1449/events","html_url":"https://github.com/jquery/jquery/pull/1449","id":23488612,"number":1449,"title":"Switch to script injection instead of indirect eval call","user":{"login":"markelog","id":945528,"avatar_url":"https://avatars.githubusercontent.com/u/945528?v=3","gravatar_id":"","url":"https://api.github.com/users/markelog","html_url":"https://github.com/markelog","followers_url":"https://api.github.com/users/markelog/followers","following_url":"https://api.github.com/users/markelog/following{/other_user}","gists_url":"https://api.github.com/users/markelog/gists{/gist_id}","starred_url":"https://api.github.com/users/markelog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markelog/subscriptions","organizations_url":"https://api.github.com/users/markelog/orgs","repos_url":"https://api.github.com/users/markelog/repos","events_url":"https://api.github.com/users/markelog/events{/privacy}","received_events_url":"https://api.github.com/users/markelog/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/jquery/jquery/milestones/2","html_url":"https://github.com/jquery/jquery/milestones/3.0.0","labels_url":"https://api.github.com/repos/jquery/jquery/milestones/2/labels","id":561714,"number":2,"title":"3.0.0","description":"","creator":{"login":"dmethvin","id":157858,"avatar_url":"https://avatars.githubusercontent.com/u/157858?v=3","gravatar_id":"","url":"https://api.github.com/users/dmethvin","html_url":"https://github.com/dmethvin","followers_url":"https://api.github.com/users/dmethvin/followers","following_url":"https://api.github.com/users/dmethvin/following{/other_user}","gists_url":"https://api.github.com/users/dmethvin/gists{/gist_id}","starred_url":"https://api.github.com/users/dmethvin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmethvin/subscriptions","organizations_url":"https://api.github.com/users/dmethvin/orgs","repos_url":"https://api.github.com/users/dmethvin/repos","events_url":"https://api.github.com/users/dmethvin/events{/privacy}","received_events_url":"https://api.github.com/users/dmethvin/received_events","type":"User","site_admin":false},"open_issues":43,"closed_issues":146,"state":"open","created_at":"2014-02-07T02:09:56Z","updated_at":"2015-07-20T16:37:53Z","due_on":null,"closed_at":null},"comments":16,"created_at":"2013-11-29T11:57:56Z","updated_at":"2015-07-22T10:59:41Z","closed_at":"2014-06-15T23:15:51Z","pull_request":{"url":"https://api.github.com/repos/jquery/jquery/pulls/1449","html_url":"https://github.com/jquery/jquery/pull/1449","diff_url":"https://github.com/jquery/jquery/pull/1449.diff","patch_url":"https://github.com/jquery/jquery/pull/1449.patch"},"body":"Right now, 2.x uses two techincs for code execution in global scope: script injection if \"use strict\" statement is found and indirect eval call if not. 1.x only uses eval path.\r\n\r\nWith indirect eval call, we have only one problem - if evaluated code uses strict pragma, it will not be executed in global scope, which subverts function purpose. Although current code tries to circumvent it, but fails on edge <a href=\"http://bugs.jquery.com/ticket/14189\">cases</a>.\r\n\r\nWith script injection we have four problems:\r\n1) It requires browser environments, i.e. DOM\r\n2) It might be executed <a href=\"http://bugs.jquery.com/ticket/7862\">asynchronously</a>\r\n3) Errors do not propagate, but instead would be thrown in different flow, meaning you can't catch them without `window.onerror`\r\n4) Potential performance penalty\r\n\r\nOne common and obvious issue is difference of `globalEval` functionality between branches. Because now we have all those problems combine, so i propose to start using only one technic, this PR will try to do it with script injection.\r\n\r\nNow about issues with this way:\r\n<blockquote>It requires browser env, i.e. DOM</blockquote>\r\nWell, jQuery is DOM-centric library, in other environments you should use other means\r\n\r\n<blockquote>It might be executed asynchronously</blockquote>\r\nIt's <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#Gecko-specific_notes\">no longer true</a>, since Firefox 4.0, but just to be sure, i added a test for it.\r\n\r\n<blockquote>Errors do not propagate</blockquote>\r\nYes, that would be a incompatible difference\r\n\r\n<blockquote>Potential perfomance penalty</blockquote>\r\nIt's actually the <a href=\"http://jsperf.com/tag-vs-eval-fn-construction\">opposite</a> (it's not my test if anyone asks :-)\r\n\r\nI think the important thing is that jQuery should use only one technic and it should be identical between branches, i, personally, could live with any of them.\r\n\r\n/cc @dmethvin, @rwaldron, @jdalton, @jaubourg"},"comment":{"url":"https://api.github.com/repos/jquery/jquery/issues/comments/123665040","html_url":"https://github.com/jquery/jquery/pull/1449#issuecomment-123665040","issue_url":"https://api.github.com/repos/jquery/jquery/issues/1449","id":123665040,"user":{"login":"mzgol","id":1758366,"avatar_url":"https://avatars.githubusercontent.com/u/1758366?v=3","gravatar_id":"","url":"https://api.github.com/users/mzgol","html_url":"https://github.com/mzgol","followers_url":"https://api.github.com/users/mzgol/followers","following_url":"https://api.github.com/users/mzgol/following{/other_user}","gists_url":"https://api.github.com/users/mzgol/gists{/gist_id}","starred_url":"https://api.github.com/users/mzgol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzgol/subscriptions","organizations_url":"https://api.github.com/users/mzgol/orgs","repos_url":"https://api.github.com/users/mzgol/repos","events_url":"https://api.github.com/users/mzgol/events{/privacy}","received_events_url":"https://api.github.com/users/mzgol/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T10:59:41Z","updated_at":"2015-07-22T10:59:41Z","body":"This PR seems to make Android fail AJAX tests even on `compat` (previously it failed only on `master`). That's one of the reasons I created #2483; supporting Android 2.3 fully would sometimes mean reverting things like this PR and I'd like to avoid catering to this browser so much."}}