Skip to content

Commit 2346a0c

Browse files
Update index.html
1 parent 1894171 commit 2346a0c

File tree

1 file changed

+7
-39
lines changed

1 file changed

+7
-39
lines changed

index.html

+7-39
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,17 @@
77
<body>
88

99

10-
<script>
11-
(function() {
12-
// Helper to check if we're on checkout/thank you pages
13-
const isCheckoutPage = window.location.pathname.includes('/checkout');
14-
const isThankYouPage = window.location.pathname.includes('/thank_you');
15-
16-
// Don't load on regular checkout pages
17-
if (isCheckoutPage && !isThankYouPage) {
18-
return;
19-
}
20-
21-
// Function to initialize the widget
22-
const initializeWidget = () => {
23-
// Add CSS first
24-
const link = document.createElement('link');
25-
link.rel = 'stylesheet';
26-
link.href = 'https://feedbackstack.test/js/core/style.css';
27-
document.head.appendChild(link);
10+
<script>
11+
(() => {
12+
// Load CSS
13+
document.head.insertAdjacentHTML('beforeend',
14+
'<link rel="stylesheet" href="https://feedbackstack.test/js/core/style.css">');
2815

29-
// Then load JS
16+
// Load and initialize widget
3017
const script = document.createElement('script');
3118
script.src = `https://feedbackstack.test/js/core/script.js?token=b19bf05984da4b073b378ba2dc3ec0b5e941ea42e0bdaf52cebe7a9051396fd2&shop=${window.location.host}`;
32-
script.onload = function() {
33-
if (typeof FeedbackWidget === 'function') {
34-
FeedbackWidget();
35-
}
36-
};
19+
script.onload = () => window.FeedbackWidget?.();
3720
document.body.appendChild(script);
38-
};
39-
40-
// If on thank you page, wait for Shopify's checkout to be ready
41-
if (isThankYouPage) {
42-
// Wait for Shopify's checkout object to be fully initialized
43-
const waitForCheckout = setInterval(() => {
44-
if (window.Shopify && window.Shopify.checkout) {
45-
clearInterval(waitForCheckout);
46-
setTimeout(initializeWidget, 1000); // Add a small delay after checkout is ready
47-
}
48-
}, 100);
49-
} else {
50-
// Regular page, initialize normally
51-
initializeWidget();
52-
}
5321
})();
5422
</script>
5523
</body>

0 commit comments

Comments
 (0)