Skip to content

Commit c3fc3db

Browse files
committed
Ensure config isn't loaded multiple times
1 parent 2fb176b commit c3fc3db

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

jupyterlite_sphinx/jupyterlite_sphinx.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,15 @@ window.tryExamplesHideIframe = (examplesContainerId, iframeParentContainerId) =>
8585
/* Global variable for try_examples iframe minHeight. Defaults to 0 but can be
8686
* modified based on configuration in try_examples.json */
8787
var tryExamplesGlobalMinHeight = 0;
88+
/* Global variable to check if config has been loaded. This keeps it from getting
89+
* loaded multiple times if there are multiple try_examples directives on one page
90+
*/
91+
var tryExamplesConfigLoaded = false;
8892

8993
window.loadTryExamplesConfig = async (configFilePath) => {
94+
if (tryExamplesConfigLoaded) {
95+
return;
96+
}
9097
try {
9198
// Add a timestamp as query parameter to ensure a cached version of the
9299
// file is not used.
@@ -130,6 +137,7 @@ window.loadTryExamplesConfig = async (configFilePath) => {
130137
} catch (error) {
131138
console.error(error);
132139
}
140+
tryExamplesConfigLoaded = true;
133141
};
134142

135143

0 commit comments

Comments
 (0)