Skip to content

Commit 793eb77

Browse files
committed
load jupyter widgets afterBody
1 parent 81849de commit 793eb77

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/core/jupyter/widgets.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,31 +98,30 @@ export function includesForJupyterWidgetDependencies(
9898
}
9999

100100
// write required dependencies into head
101-
const head: string[] = [];
101+
const afterBody: string[] = [];
102102
if (haveJavascriptWidgets || haveJupyterWidgets) {
103-
head.push(
103+
afterBody.push(
104104
'<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" integrity="sha512-c3Nl8+7g4LMSTdrm621y7kf9v3SDPnhxLNhcjFJbKECVnmZHTdo+IRO05sNLTH/D3vA6u1X32ehoLC7WFVdheg==" crossorigin="anonymous"></script>',
105105
);
106-
head.push(
106+
afterBody.push(
107107
'<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>',
108108
);
109-
head.push(
109+
afterBody.push(
110110
"<script type=\"application/javascript\">define('jquery', [],function() {return window.jQuery;})</script>",
111111
);
112112
}
113113

114114
// html libraries (e.g. plotly)
115-
head.push(...htmlLibraries);
115+
afterBody.push(...htmlLibraries);
116116

117117
// jupyter widget runtime
118118
if (haveJupyterWidgets) {
119-
head.push(
119+
afterBody.push(
120120
'<script src="https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd.js" crossorigin="anonymous"></script>',
121121
);
122122
}
123123

124124
// write jupyter widget state after body if it exists
125-
const afterBody: string[] = [];
126125
if (haveJupyterWidgets && widgetsState) {
127126
afterBody.push(`<script type=${kApplicationJupyterWidgetState}>`);
128127
afterBody.push(
@@ -144,9 +143,6 @@ export function includesForJupyterWidgetDependencies(
144143
inHeader: "",
145144
afterBody: "",
146145
};
147-
if (head.length > 0) {
148-
result.inHeader = widgetTempFile(head);
149-
}
150146
if (afterBody.length > 0) {
151147
result.afterBody = widgetTempFile(afterBody);
152148
}

0 commit comments

Comments
 (0)