Add logic to load main script only if not already loaded
This commit is contained in:
@ -41,6 +41,18 @@ templ BaseAuth(title string){
|
|||||||
<div id="content">
|
<div id="content">
|
||||||
{ children... }
|
{ children... }
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function addScript() {
|
||||||
|
if (!window.scriptAdded) {
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.src = "/public/main.js";
|
||||||
|
window.scriptAdded = true;
|
||||||
|
script.onerror = onerror;
|
||||||
|
document.head.appendChild(script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addScript()
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user