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">
|
||||
{ children... }
|
||||
</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>
|
||||
</html>
|
||||
}
|
||||
|
Reference in New Issue
Block a user