I am trying to combine 5 external .js into 1 .js named defer.js
I really don't get it what I am doing wrong..
This are external .js:
https://xx.com/journal-cache/_b88d0ea5b ... 6642eee.js
https://platform-api.sharethis.com/js/s ... iance-tool
https://xx.com/journal-cache/_b7bb2e4eb ... a4cc761.js
https://cc.cdn.civiccomputing.com/8.0/c ... 8.0.min.js
https://xx.com/cdn-cgi/apps/head/8MWZuj ... fH3l-iM.js
https://xx.com/cdn-cgi/scripts/5c5dd728 ... ode.min.js
So I created 1 .js named defer.js that starts with <script> and ends with </script> and put all those 5 scripts into one.. with 1 enter space for each .js
than I added this code under footer.tpl before </body> ends..
Code: Select all
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "defer.js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
</script>
Can please someone help me with this? I would really appreciate it.
I tried to follow this instructions but doesn't work https://varvy.com/pagespeed/defer-loadi ... cript.html
I am using OC 2.3.0.2. HELP!