Last active
May 18, 2023 07:19
-
-
Save taoka-toshiaki/a4b8312d69631a7d00e86d3b33839019 to your computer and use it in GitHub Desktop.
jsとcssファイルを再読み込みするだけのコード。(パラメータを含むものには非対応)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
document.querySelector("button").addEventListener("click",jsandcssreload); | |
function jsandcssreload(){ | |
let d = (new Date()).getTime(); | |
[...document.querySelectorAll("link")].forEach((elm)=>{ | |
elm.href = elm.href.replace(/(\.css)\??[0-9]{0,}$/,".css?" + d); | |
}); | |
[...document.querySelectorAll("script")].forEach((elm)=>{ | |
elm.src = elm.src.replace(/(\.js)\??[0-9]{0,}$/,".js?" + d); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment