HTML伪JS动态加载代码:

<script type="text/javascript">
function linkCache() {
    this.exexute = function()
    {
        let a = document.querySelectorAll('a');
        let filterLink = [
            ''
        ]; // 过滤不需要伪JS动态加载的链接
        for(let i = 0; i < a.length; i++)
        {
            let froa = a[i];
            if(/^(http|\/\/).+$/img.test(froa) && fora.host == window.location.host && filterLink.indexOf(fora.href) == -1)
            {
                let link = froa.href;
                froa.href = 'javascript:void(0)';
                froa.target = '_self';
                froa.onclick = function()
                {
                    self.load(link);
                }
            }
        }
    }
    self.load = function(link)
    {
        let cDiv = document.createElement('div');
        cDiv.style.cssText = 'position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 99999999999999999; background: #000000; opacity: 0.3;';
        let cLoading = document.createElement('div');
        cLoading.id = 'loading';
        cLoading.style.cssText = 'width: 26px; height: 26px; position: fixed; top: calc(50% - 16px); right: calc(50% - 16px); border: 3px solid white; border-left: 3px solid transparent; border-right: 3px solid transparent; border-radius: 100%; z-index: 999999999999999999; ';
        cLoadingStyle = document.createElement('style');
        cLoadingStyle.type = 'text/css';
        cLoadingStyle.innerHTML = '#loading {animation: loading 666ms infinite; animation-timing-function: linear;} @keyframes loading {100% {transform: rotate(360deg);}}';
        let cLoad = document.createElement('script');
        cLoad.src = link;
        cLoad.onload = function()
        {
            let shref = window.location.href;
            // window.location.replace(link); // referrer会丢失
            let cA = document.createElement('a');
            cA.href = link;
            cA.target = '_self';
            cA.style.cssText = 'opacity: 0;';
            document.body.appendChild(cA);
            cA.click();
            document.body.removeChild(cA);
            setTimeout(function() {
                document.body.removeChild(cDiv);
                document.body.removeChild(cLoading);
                document.body.removeChild(cLoadingStyle);
                document.body.removeChild(cLoad);
            }, 666);
        }
        cLoad.onerror =function() {
            let cTips = document.createElement('div');
            cTips.style.cssText = 'width: 86px; height: 36px; text-align: center; font-size: 16px; padding: 5px 0px; position: fixed; top: calc(50% - 12px); right: calc(50% - 46px); border-radius: 6px; background: red; color: #ffffff; z-index: 999999999999999999; transition: all 333ms;';
            cTips.innerHTML = '载入失败';
            document.body.removeChild(cDiv);
            document.body.removeChild(cLoading);
            document.body.removeChild(cLoadingStyle);
            document.body.removeChild(cLoad);
            document.body.appendChild(cTips);
            setTimeout(function()
            {
                cTips.style.opacity = '0';
            }, 1000);
            setTimeout(function()
            {
                document.body.removeChild(cTips);
            }, 1333);
        }
        document.body.appendChild(cDiv);
        document.body.appendChild(cLoading);
        document.body.appendChild(cLoadingStyle);
        document.body.appendChild(cLoad);
    }
}
window.onload = function()
{
    try
    {
        var elc = new linkCache();
        elc.exexute();
    }catch (e) {console.log(e)} // 如果发生错误,将停止执行
}
</script>

把该代码放置<head></head>标签之间即可。