diff --git a/gatsby-browser.js b/gatsby-browser.js
index 0f15d568..dfa6b6a4 100644
--- a/gatsby-browser.js
+++ b/gatsby-browser.js
@@ -15,6 +15,7 @@ export const onClientEntry = () => {
import React from 'react';
import { Provider } from 'jotai';
+
import { BeaconProvider } from './src/context/beacon-context';
export const wrapRootElement = ({ element }) => {
@@ -24,3 +25,47 @@ export const wrapRootElement = ({ element }) => {
);
};
+
+const addScript = url => {
+ const script = document.createElement('script');
+ script.src = url;
+ script.async = true;
+ script.type = 'text/javascript';
+ script.charSet = 'utf-8';
+ document.body.appendChild(script);
+};
+
+export const onRouteUpdate = ({ location, prevLocation }) => {
+ /*
+ 1. Check if the URL contains 'module-02' or 'module-03'
+ 2. If the URL has the keywords, check if SmartPy script is added or not.
+ 3. If SmartPy script isn't added -> add the necessary scripts.
+ */
+ if (
+ location.pathname.indexOf('module-02') != -1 ||
+ location.pathname.indexOf('module-03') != -1
+ ) {
+ // checking is '/smartpyio.py' script is added or not.
+ const scripts = Array.from(document.querySelectorAll('script'));
+ const srcVals = scripts
+ .filter(sc => typeof sc.attributes.src != 'undefined')
+ .map(sc => sc.attributes.src.value);
+ const hasSmartpy = srcVals.indexOf('/smartpyio.py');
+
+ if (hasSmartpy == -1) {
+ // adding the necessary scripts
+ addScript('/execute.js');
+ addScript('/smartjs/smart.js');
+ addScript('/smartjs/smartmljs.bc.js');
+
+ const script = document.createElement('script');
+ script.src = '/smartpyio.py';
+ script.type = 'text/python';
+ document.body.appendChild(script);
+ if (typeof window.brython != 'undefined') {
+ // Initialize brython
+ brython({ debug: 1, indexedDB: false, pythonpath: '/' });
+ }
+ }
+ }
+};
diff --git a/src/assets/wealth.png b/src/assets/wealth.png
deleted file mode 100644
index ddc1db6a..00000000
Binary files a/src/assets/wealth.png and /dev/null differ
diff --git a/src/assets/wealth.webp b/src/assets/wealth.webp
new file mode 100644
index 00000000..06deacd0
Binary files /dev/null and b/src/assets/wealth.webp differ
diff --git a/src/html.js b/src/html.js
index e967811e..51066825 100644
--- a/src/html.js
+++ b/src/html.js
@@ -24,42 +24,50 @@ export default function HTML(props) {
type="text/javascript"
charSet="utf-8"
async
+ defer
>
+ {/*
+ defer
+ > */}
{props.headComponents}
@@ -71,7 +79,7 @@ export default function HTML(props) {
dangerouslySetInnerHTML={{ __html: props.body }}
/>
{props.postBodyComponents}
-
+ {/* */}