{"action":"created","comment":{"url":"https://api.github.com/repos/bokeh/bokeh/pulls/comments/61816913","id":61816913,"diff_hunk":"@@ -25,96 +25,94 @@ calls it with the rendered model.\n \n \n #}\n-document.addEventListener(\"DOMContentLoaded\", function(event) { \n-  (function(global) {\n-    function now() {\n-      return new Date();\n+(function(global) {\n+  function now() {\n+    return new Date();\n+  }\n+\n+  if (typeof (window._bokeh_onload_callbacks) === \"undefined\") {\n+    window._bokeh_onload_callbacks = [];\n+  }\n+\n+  function run_callbacks() {\n+    window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n+    delete window._bokeh_onload_callbacks\n+    console.info(\"Bokeh: all callbacks have finished\");\n+  }\n+\n+  function load_libs(js_urls, callback) {\n+    window._bokeh_onload_callbacks.push(callback);\n+    if (window._bokeh_is_loading > 0) {\n+      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n+      return null;\n     }\n-\n-    if (typeof (window._bokeh_onload_callbacks) === \"undefined\") {\n-      window._bokeh_onload_callbacks = [];\n-    }\n-\n-    function run_callbacks() {\n-      window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n-      delete window._bokeh_onload_callbacks\n-      console.info(\"Bokeh: all callbacks have finished\");\n+    if (js_urls == null || js_urls.length === 0) {\n+      run_callbacks();\n+      return null;\n     }\n-\n-    function load_libs(js_urls, callback) {\n-      window._bokeh_onload_callbacks.push(callback);\n-      if (window._bokeh_is_loading > 0) {\n-        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n-        return null;\n-      }\n-      if (js_urls == null || js_urls.length === 0) {\n-        run_callbacks();\n-        return null;\n-      }\n-      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n-      window._bokeh_is_loading = js_urls.length;\n-      for (var i = 0; i < js_urls.length; i++) {\n-        var url = js_urls[i];\n-        var s = document.createElement('script');\n-        s.src = url;\n-        s.async = false;\n-        s.onreadystatechange = s.onload = function() {\n-          window._bokeh_is_loading--;\n-          if (window._bokeh_is_loading === 0) {\n-            console.log(\"Bokeh: all BokehJS libraries loaded\");\n-            run_callbacks()\n-          }\n-        };\n-        s.onerror = function() {\n-          console.warn(\"failed to load library \" + url);\n-        };\n-        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n-        document.getElementsByTagName(\"head\")[0].appendChild(s);\n-      }\n-    };\n-\n-    {%- if elementid -%}\n-    var element = document.getElementById(\"{{ elementid }}\");\n-    if (element == null) {\n-      console.log(\"Bokeh: ERROR: autoload.js configured with elementid '{{ elementid }}' but no matching script tag was found. \")\n-      return false;\n+    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n+    window._bokeh_is_loading = js_urls.length;\n+    for (var i = 0; i < js_urls.length; i++) {\n+      var url = js_urls[i];\n+      var s = document.createElement('script');\n+      s.src = url;\n+      s.async = false;\n+      s.onreadystatechange = s.onload = function() {\n+        window._bokeh_is_loading--;\n+        if (window._bokeh_is_loading === 0) {\n+          console.log(\"Bokeh: all BokehJS libraries loaded\");\n+          run_callbacks()\n+        }\n+      };\n+      s.onerror = function() {\n+        console.warn(\"failed to load library \" + url);\n+      };\n+      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n+      document.getElementsByTagName(\"head\")[0].appendChild(s);\n     }\n-    {%- endif %}\n-\n-    var js_urls = {{ js_urls }};\n-\n-    var inline_js = [\n-      {%- for js in js_raw %}\n-      function(Bokeh) {\n-        {{ js|indent(6) }}\n-      },\n-      {% endfor -%}\n-      function(Bokeh) {\n-        {%- for url in css_urls %}\n-        console.log(\"Bokeh: injecting CSS: {{ url }}\");\n-        Bokeh.embed.inject_css(\"{{ url }}\");\n-        {%- endfor %}\n-        {%- for css in css_raw %}\n-        console.log(\"Bokeh: injecting raw CSS\");\n-        Bokeh.embed.inject_raw_css({{ css }});\n-        {%- endfor %}\n-      }\n-    ];\n-\n-    function run_inline_js() {\n-      for (var i = 0; i < inline_js.length; i++) {\n-        inline_js[i](window.Bokeh);\n-      }\n+  };\n+\n+  {%- if elementid -%}\n+  var element = document.getElementById(\"{{ elementid }}\");\n+  if (element == null) {\n+    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '{{ elementid }}' but no matching script tag was found. \")\n+    return false;\n+  }\n+  {%- endif %}\n+\n+  var js_urls = {{ js_urls }};\n+\n+  var inline_js = [\n+    {%- for js in js_raw %}\n+    function(Bokeh) {\n+      {{ js|indent(6) }}\n+    },\n+    {% endfor -%}\n+    function(Bokeh) {\n+      {%- for url in css_urls %}\n+      console.log(\"Bokeh: injecting CSS: {{ url }}\");\n+      Bokeh.embed.inject_css(\"{{ url }}\");\n+      {%- endfor %}\n+      {%- for css in css_raw %}\n+      console.log(\"Bokeh: injecting raw CSS\");\n+      Bokeh.embed.inject_raw_css({{ css }});\n+      {%- endfor %}\n     }\n+  ];\n \n-    if (window._bokeh_is_loading === 0) {\n-      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n-      run_inline_js();\n-    } else {\n-      load_libs(js_urls, function() {\n-        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n-        run_inline_js();\n-      });\n+  function run_inline_js() {\n+    for (var i = 0; i < inline_js.length; i++) {\n+      inline_js[i](window.Bokeh);\n     }\n-  }(this));\n-});\n+  }\n+\n+  if (window._bokeh_is_loading === 0) {\n+    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n+    run_inline_js();\n+  } else {\n+    load_libs(js_urls, function() {\n+      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n+      run_inline_js();\n+    });\n+  }\n+}(this));","path":"bokeh/core/_templates/autoload_js.js","position":181,"original_position":181,"commit_id":"8ac3f9e258340afd6fb4ee693c994a13f1826a86","original_commit_id":"8ac3f9e258340afd6fb4ee693c994a13f1826a86","user":{"login":"mattpap","id":27475,"avatar_url":"https://avatars.githubusercontent.com/u/27475?v=3","gravatar_id":"","url":"https://api.github.com/users/mattpap","html_url":"https://github.com/mattpap","followers_url":"https://api.github.com/users/mattpap/followers","following_url":"https://api.github.com/users/mattpap/following{/other_user}","gists_url":"https://api.github.com/users/mattpap/gists{/gist_id}","starred_url":"https://api.github.com/users/mattpap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattpap/subscriptions","organizations_url":"https://api.github.com/users/mattpap/orgs","repos_url":"https://api.github.com/users/mattpap/repos","events_url":"https://api.github.com/users/mattpap/events{/privacy}","received_events_url":"https://api.github.com/users/mattpap/received_events","type":"User","site_admin":false},"body":"I presume this is just shift left and removal of the wrapper? I just can't read this diff.","created_at":"2016-05-02T22:36:20Z","updated_at":"2016-05-02T22:36:20Z","html_url":"https://github.com/bokeh/bokeh/pull/4264#discussion_r61816913","pull_request_url":"https://api.github.com/repos/bokeh/bokeh/pulls/4264","_links":{"self":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/comments/61816913"},"html":{"href":"https://github.com/bokeh/bokeh/pull/4264#discussion_r61816913"},"pull_request":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/4264"}}},"pull_request":{"url":"https://api.github.com/repos/bokeh/bokeh/pulls/4264","id":68596347,"html_url":"https://github.com/bokeh/bokeh/pull/4264","diff_url":"https://github.com/bokeh/bokeh/pull/4264.diff","patch_url":"https://github.com/bokeh/bokeh/pull/4264.patch","issue_url":"https://api.github.com/repos/bokeh/bokeh/issues/4264","number":4264,"state":"open","locked":false,"title":"only wrap autoload_static in an onload handler","user":{"login":"bryevdv","id":1078448,"avatar_url":"https://avatars.githubusercontent.com/u/1078448?v=3","gravatar_id":"","url":"https://api.github.com/users/bryevdv","html_url":"https://github.com/bryevdv","followers_url":"https://api.github.com/users/bryevdv/followers","following_url":"https://api.github.com/users/bryevdv/following{/other_user}","gists_url":"https://api.github.com/users/bryevdv/gists{/gist_id}","starred_url":"https://api.github.com/users/bryevdv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryevdv/subscriptions","organizations_url":"https://api.github.com/users/bryevdv/orgs","repos_url":"https://api.github.com/users/bryevdv/repos","events_url":"https://api.github.com/users/bryevdv/events{/privacy}","received_events_url":"https://api.github.com/users/bryevdv/received_events","type":"User","site_admin":false},"body":"issues: fixes #4254\r\n\r\nThis PR changes the embedding code to only wrap the JS for `autoload_static` in a document `onload` handler, and reverts the notebook embedding code to the way it was previously. \r\n\r\nI have verified that the notebook functions with this PR. \r\n\r\n@seanlaw if possible, can you check whether `autoload_static` functions as expected for you? (Looking at the output in an ipython console, it looks good, but independent verification is certainly welcome)\r\n\r\n@mattpap I do want to take a deeper dive into all of our embedding/templating soon, but I'd like to get your opinion if this is acceptable as an immediate fix. ","created_at":"2016-05-02T18:07:02Z","updated_at":"2016-05-02T22:36:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c74d308483654e75cb8be04b7089041f7b570dde","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bokeh/bokeh/pulls/4264/commits","review_comments_url":"https://api.github.com/repos/bokeh/bokeh/pulls/4264/comments","review_comment_url":"https://api.github.com/repos/bokeh/bokeh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bokeh/bokeh/issues/4264/comments","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/8ac3f9e258340afd6fb4ee693c994a13f1826a86","head":{"label":"bokeh:bryanv/4254_notebook","ref":"bryanv/4254_notebook","sha":"8ac3f9e258340afd6fb4ee693c994a13f1826a86","user":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"repo":{"id":3834332,"name":"bokeh","full_name":"bokeh/bokeh","owner":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bokeh/bokeh","description":"Interactive Web Plotting for Python","fork":false,"url":"https://api.github.com/repos/bokeh/bokeh","forks_url":"https://api.github.com/repos/bokeh/bokeh/forks","keys_url":"https://api.github.com/repos/bokeh/bokeh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bokeh/bokeh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bokeh/bokeh/teams","hooks_url":"https://api.github.com/repos/bokeh/bokeh/hooks","issue_events_url":"https://api.github.com/repos/bokeh/bokeh/issues/events{/number}","events_url":"https://api.github.com/repos/bokeh/bokeh/events","assignees_url":"https://api.github.com/repos/bokeh/bokeh/assignees{/user}","branches_url":"https://api.github.com/repos/bokeh/bokeh/branches{/branch}","tags_url":"https://api.github.com/repos/bokeh/bokeh/tags","blobs_url":"https://api.github.com/repos/bokeh/bokeh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bokeh/bokeh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bokeh/bokeh/git/refs{/sha}","trees_url":"https://api.github.com/repos/bokeh/bokeh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/{sha}","languages_url":"https://api.github.com/repos/bokeh/bokeh/languages","stargazers_url":"https://api.github.com/repos/bokeh/bokeh/stargazers","contributors_url":"https://api.github.com/repos/bokeh/bokeh/contributors","subscribers_url":"https://api.github.com/repos/bokeh/bokeh/subscribers","subscription_url":"https://api.github.com/repos/bokeh/bokeh/subscription","commits_url":"https://api.github.com/repos/bokeh/bokeh/commits{/sha}","git_commits_url":"https://api.github.com/repos/bokeh/bokeh/git/commits{/sha}","comments_url":"https://api.github.com/repos/bokeh/bokeh/comments{/number}","issue_comment_url":"https://api.github.com/repos/bokeh/bokeh/issues/comments{/number}","contents_url":"https://api.github.com/repos/bokeh/bokeh/contents/{+path}","compare_url":"https://api.github.com/repos/bokeh/bokeh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bokeh/bokeh/merges","archive_url":"https://api.github.com/repos/bokeh/bokeh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bokeh/bokeh/downloads","issues_url":"https://api.github.com/repos/bokeh/bokeh/issues{/number}","pulls_url":"https://api.github.com/repos/bokeh/bokeh/pulls{/number}","milestones_url":"https://api.github.com/repos/bokeh/bokeh/milestones{/number}","notifications_url":"https://api.github.com/repos/bokeh/bokeh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bokeh/bokeh/labels{/name}","releases_url":"https://api.github.com/repos/bokeh/bokeh/releases{/id}","deployments_url":"https://api.github.com/repos/bokeh/bokeh/deployments","created_at":"2012-03-26T15:40:01Z","updated_at":"2016-05-02T11:02:07Z","pushed_at":"2016-05-02T21:38:43Z","git_url":"git://github.com/bokeh/bokeh.git","ssh_url":"git@github.com:bokeh/bokeh.git","clone_url":"https://github.com/bokeh/bokeh.git","svn_url":"https://github.com/bokeh/bokeh","homepage":"http://bokeh.pydata.org/en/latest/","size":176072,"stargazers_count":4132,"watchers_count":4132,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":855,"mirror_url":null,"open_issues_count":641,"forks":855,"open_issues":641,"watchers":4132,"default_branch":"master"}},"base":{"label":"bokeh:master","ref":"master","sha":"ac9c58ca447148333b0fa2e3de55af879a96a4cf","user":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"repo":{"id":3834332,"name":"bokeh","full_name":"bokeh/bokeh","owner":{"login":"bokeh","id":8440965,"avatar_url":"https://avatars.githubusercontent.com/u/8440965?v=3","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bokeh/bokeh","description":"Interactive Web Plotting for Python","fork":false,"url":"https://api.github.com/repos/bokeh/bokeh","forks_url":"https://api.github.com/repos/bokeh/bokeh/forks","keys_url":"https://api.github.com/repos/bokeh/bokeh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bokeh/bokeh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bokeh/bokeh/teams","hooks_url":"https://api.github.com/repos/bokeh/bokeh/hooks","issue_events_url":"https://api.github.com/repos/bokeh/bokeh/issues/events{/number}","events_url":"https://api.github.com/repos/bokeh/bokeh/events","assignees_url":"https://api.github.com/repos/bokeh/bokeh/assignees{/user}","branches_url":"https://api.github.com/repos/bokeh/bokeh/branches{/branch}","tags_url":"https://api.github.com/repos/bokeh/bokeh/tags","blobs_url":"https://api.github.com/repos/bokeh/bokeh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bokeh/bokeh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bokeh/bokeh/git/refs{/sha}","trees_url":"https://api.github.com/repos/bokeh/bokeh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/{sha}","languages_url":"https://api.github.com/repos/bokeh/bokeh/languages","stargazers_url":"https://api.github.com/repos/bokeh/bokeh/stargazers","contributors_url":"https://api.github.com/repos/bokeh/bokeh/contributors","subscribers_url":"https://api.github.com/repos/bokeh/bokeh/subscribers","subscription_url":"https://api.github.com/repos/bokeh/bokeh/subscription","commits_url":"https://api.github.com/repos/bokeh/bokeh/commits{/sha}","git_commits_url":"https://api.github.com/repos/bokeh/bokeh/git/commits{/sha}","comments_url":"https://api.github.com/repos/bokeh/bokeh/comments{/number}","issue_comment_url":"https://api.github.com/repos/bokeh/bokeh/issues/comments{/number}","contents_url":"https://api.github.com/repos/bokeh/bokeh/contents/{+path}","compare_url":"https://api.github.com/repos/bokeh/bokeh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bokeh/bokeh/merges","archive_url":"https://api.github.com/repos/bokeh/bokeh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bokeh/bokeh/downloads","issues_url":"https://api.github.com/repos/bokeh/bokeh/issues{/number}","pulls_url":"https://api.github.com/repos/bokeh/bokeh/pulls{/number}","milestones_url":"https://api.github.com/repos/bokeh/bokeh/milestones{/number}","notifications_url":"https://api.github.com/repos/bokeh/bokeh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bokeh/bokeh/labels{/name}","releases_url":"https://api.github.com/repos/bokeh/bokeh/releases{/id}","deployments_url":"https://api.github.com/repos/bokeh/bokeh/deployments","created_at":"2012-03-26T15:40:01Z","updated_at":"2016-05-02T11:02:07Z","pushed_at":"2016-05-02T21:38:43Z","git_url":"git://github.com/bokeh/bokeh.git","ssh_url":"git@github.com:bokeh/bokeh.git","clone_url":"https://github.com/bokeh/bokeh.git","svn_url":"https://github.com/bokeh/bokeh","homepage":"http://bokeh.pydata.org/en/latest/","size":176072,"stargazers_count":4132,"watchers_count":4132,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":855,"mirror_url":null,"open_issues_count":641,"forks":855,"open_issues":641,"watchers":4132,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/4264"},"html":{"href":"https://github.com/bokeh/bokeh/pull/4264"},"issue":{"href":"https://api.github.com/repos/bokeh/bokeh/issues/4264"},"comments":{"href":"https://api.github.com/repos/bokeh/bokeh/issues/4264/comments"},"review_comments":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/4264/comments"},"review_comment":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/4264/commits"},"statuses":{"href":"https://api.github.com/repos/bokeh/bokeh/statuses/8ac3f9e258340afd6fb4ee693c994a13f1826a86"}}}}