assets/js/wordfinder-home.js in word-games-theme-2.6.1 vs assets/js/wordfinder-home.js in word-games-theme-2.6.2
- old
+ new
@@ -76,10 +76,11 @@
let resourceEle;
if (type === "text/javascript") {
resourceEle = document.createElement("script");
resourceEle.src = FILE_URL;
+ resourceEle.classList.add("loaded-js");
} else if (type === "text/css") {
resourceEle = document.createElement("link");
resourceEle.rel = "stylesheet";
resourceEle.href = FILE_URL;
} else {
@@ -189,27 +190,30 @@
if (new URLSearchParams(window.location.search).has(paramName)) {
const additionalData = {
url: "{{site.url}}",
range: "{{page.blanktilerange}}"
}
- loadResource("/assets/css/wordfinder-result.css", additionalData, true, "text/css")
- .then((data) => {
- console.log("CSS loaded:", data);
- })
- .then(() => {
- // Load the JavaScript file after the CSS file has loaded
- loadResource("/assets/js/wordfinder.js", additionalData, true, "text/javascript")
- .then((data) => {
- console.log("JavaScript loaded:", data);
- getData(txtBox.value.toLowerCase());
- })
- .catch((error) => {
- console.error("Error loading JavaScript:", error);
- });
- })
- .catch((error) => {
- console.error("Error loading CSS:", error);
- });
+ var loadJs = document.querySelector(".loaded-js");
+ if (loadJs == null) {
+ loadResource("/assets/css/wordfinder-result.css", additionalData, true, "text/css")
+ .then((data) => {
+ console.log("CSS loaded:", data);
+ })
+ .then(() => {
+ // Load the JavaScript file after the CSS file has loaded
+ loadResource("/assets/js/wordfinder.js", additionalData, true, "text/javascript")
+ .then((data) => {
+ console.log("JavaScript loaded:", data);
+ getData(txtBox.value.toLowerCase());
+ })
+ .catch((error) => {
+ console.error("Error loading JavaScript:", error);
+ });
+ })
+ .catch((error) => {
+ console.error("Error loading CSS:", error);
+ });
+ }
}
});
// Now you can use the loadScript function with additional data
function checkQueryParam() {
const urlParams = new URLSearchParams(window.location.search);