diff --git a/themes/hugo-theme-flat/layouts/partials/head.html b/themes/hugo-theme-flat/layouts/partials/head.html
index 754f16f..97dec1a 100644
--- a/themes/hugo-theme-flat/layouts/partials/head.html
+++ b/themes/hugo-theme-flat/layouts/partials/head.html
@@ -78,6 +78,6 @@
-
+
\ No newline at end of file
diff --git a/themes/hugo-theme-flat/static/js/href_handling.js b/themes/hugo-theme-flat/static/js/href_handling.js
new file mode 100644
index 0000000..ebff720
--- /dev/null
+++ b/themes/hugo-theme-flat/static/js/href_handling.js
@@ -0,0 +1,18 @@
+
+document.addEventListener("DOMContentLoaded", function() {
+document.querySelectorAll('a').forEach(function(element) {
+ const myhost = window.location.hostname;
+ const linkhost=new URL(element.href).hostname;
+ if(myhost === linkhost) {
+ let prefetchUrl=new URL(element.href).toString()
+ // lest make a prefetch tag for this url
+ let link = document.createElement('link');
+ link.setAttribute('rel', 'prefetch');
+ link.setAttribute('href', prefetchUrl);
+ link.setAttribute('as', 'document');
+ document.head.appendChild(link);
+ }else {
+ element.setAttribute("target", "_blank");
+ }
+})
+});
\ No newline at end of file
diff --git a/themes/hugo-theme-flat/static/js/layout.js b/themes/hugo-theme-flat/static/js/layout.js
deleted file mode 100644
index e1ffb4b..0000000
--- a/themes/hugo-theme-flat/static/js/layout.js
+++ /dev/null
@@ -1,9 +0,0 @@
-
-document.addEventListener("DOMContentLoaded", function() {
-document.querySelectorAll('a[href^="http"]').forEach(function(element) {
- const myhost = window.location.hostname;
- const linkhost=new URL(element.href).hostname;
- if(myhost === linkhost) return;
- element.setAttribute("target","_blank");
-})
-});
\ No newline at end of file