Defer Java Script Confusion
-
About the above topic:
Where do I keep my external JS file? In the theme directory?
Then what about the code to call the external JS file as shown below:[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]
<em><script type="text/javascript"> function deferJSWordPress() { var element = document.createElement("script"); element.src = "defer.js"; document.body.appendChild(element); } if (window.addEventListener) window.addEventListener("load", deferJSWordPress, false); else if (window.attachEvent) window.attachEvent("onload", deferJSWordPress); else window.onload = deferJSWordPress; </script> </body> </html></em>
If my javascript external file is called defer.js, then I just add the word “defer.js” as shown above? Or do I have to indicate its path way. Meaning like this: wp-content/theme/name of theme/defer.js?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Defer Java Script Confusion’ is closed to new replies.