Enhance CSS and JS injection: add cache-buster to prevent caching issues

This commit is contained in:
CodeDevMLH
2026-02-26 21:53:34 +01:00
parent b0fae10aa1
commit 69adc64a44

View File

@@ -511,11 +511,11 @@
const container = document.querySelector('.seasonals-container');
container.className = `seasonals-container ${containerClass}`;
// Inject CSS
// Inject CSS with cache-buster
if (cssFile) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = cssFile;
link.href = cssFile + '?v=' + new Date().getTime();
link.setAttribute('data-seasonal', 'true');
link.onerror = () => console.error(`[Test Site] Failed to load CSS: ${cssFile}`);
document.head.appendChild(link);
@@ -525,7 +525,7 @@
if (jsFile) {
setTimeout(async () => {
try {
const response = await fetch(jsFile);
const response = await fetch(jsFile + '?v=' + new Date().getTime());
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const code = await response.text();