-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache.js
41 lines (36 loc) · 1.2 KB
/
cache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//(function() {
var version = '1.1.1'; // Change this version number whenever you make updates
// List of files to update
var filesToCacheBust = [
'CSS/style.css',
'index.html',
'soon.html'
'INFO/index.html'
];
// Function to append version query string to URLs
function cacheBust(url) {
return url + '?v=' + version;
}
// Update link tags for CSS
var linkTags = document.querySelectorAll('link[rel="stylesheet"]');
linkTags.forEach(function(link) {
link.href = cacheBust(link.href);
});
// Update script tags for JavaScript
var scriptTags = document.querySelectorAll('script[src]');
scriptTags.forEach(function(script) {
script.src = cacheBust(script.src);
});
// Update other specific files
filesToCacheBust.forEach(function(file) {
var elements = document.querySelectorAll('[src="' + file + '"], [href="' + file + '"]');
elements.forEach(function(element) {
if (element.src) {
element.src = cacheBust(element.src);
}
if (element.href) {
element.href = cacheBust(element.href);
}
});
});
})();