diff --git a/src/client/app/emotionCache.ts b/src/client/app/emotionCache.ts
new file mode 100644
index 0000000000..cac1f322ac
--- /dev/null
+++ b/src/client/app/emotionCache.ts
@@ -0,0 +1,16 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import createCache from '@emotion/cache';
+
+//creates the nonce for the script being run
+//the nonce works alongside the webpack_nonce and plotly_nonce to protect against unwanted scripts
+const nonce = (document.querySelector('script[nonce]') as HTMLScriptElement | null)?.nonce;
+
+const emotionCache = createCache({
+ key: 'css',
+ nonce: nonce
+});
+
+export default emotionCache;
diff --git a/src/client/app/index.tsx b/src/client/app/index.tsx
index 83dfee7ad8..8a1d9c6465 100644
--- a/src/client/app/index.tsx
+++ b/src/client/app/index.tsx
@@ -10,6 +10,38 @@ import { store } from './store';
import RouteComponent from './components/RouteComponent';
import { initApp } from './redux/slices/appStateSlice';
import './styles/index.css';
+import { CacheProvider } from '@emotion/react';
+import emotionCache from './emotionCache';
+
+//these lines take the nonce, and create the webpack and plotly nonces from it
+//these are additional nonces that contribute to styling with webpack and plotly
+const __webpack_nonce__ = (document.querySelector('script[nonce]') as HTMLScriptElement | null)?.nonce;
+(window as any).__webpack_nonce__ = __webpack_nonce__;
+(window as any).__plotly_nonce__ = __webpack_nonce__;
+
+declare global {
+ interface Window {
+ __webpack_nonce__?: string;
+ __plotly_nonce__?: string;
+ }
+}
+
+
+const originalAppendChild = document.head.appendChild;
+document.head.appendChild = function (node: any) {
+ if (
+ node instanceof HTMLStyleElement
+ ) {
+ node.setAttribute('nonce', __webpack_nonce__ || '');
+ }
+
+ try {
+ return originalAppendChild.call(this, node);
+ } catch (err) {
+ console.error('Failed to append style:', err);
+ throw err;
+ }
+};
store.dispatch(initApp());
@@ -19,7 +51,9 @@ const root = createRoot(container);
root.render(
// Provides the Redux store to all child components
- < Provider store={store} stabilityCheck='always' >
- < RouteComponent />
-
+