Title: External Javascript File Not Working
Last modified: August 21, 2016

---

# External Javascript File Not Working

 *  Resolved [kertoon](https://wordpress.org/support/users/kertoon/)
 * (@kertoon)
 * [12 years ago](https://wordpress.org/support/topic/external-javascript-file-not-working-1/)
 * I am trying to combine javascript together as one external file to defer loading.
   I am not sure am I doing the correct thing. I got the javascript upload into 
   my root directory in a .js file.
 * Then I paste the the code below below before the </body> tag.
 *     ```
       <script defer="defer" type="text/javascript">
           window.onload=function(){
               var mycode;
               mycode=document.createElement("script");
               mycode.type="text/javascript";
               mycode.src="http://www.my site name.com/my external javascript file end with .js";
               document.getElementsByTagName("head")[0].appendChild(mycode);
           }
       </script>
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [john_bryan](https://wordpress.org/support/users/john_bryan/)
 * (@john_bryan)
 * [12 years ago](https://wordpress.org/support/topic/external-javascript-file-not-working-1/#post-4914489)
 * Are you getting any errors?
 *  Thread Starter [kertoon](https://wordpress.org/support/users/kertoon/)
 * (@kertoon)
 * [12 years ago](https://wordpress.org/support/topic/external-javascript-file-not-working-1/#post-4914494)
 * I am not too sure. As for the external file link is working. It is just that 
   according to the page speed tool Pingdom Tool , the Combine external JavaScript
   has no effect.
 *  [john_bryan](https://wordpress.org/support/users/john_bryan/)
 * (@john_bryan)
 * [12 years ago](https://wordpress.org/support/topic/external-javascript-file-not-working-1/#post-4914495)
 * Because according to pingdom, the page is finished loading. I doubt it executes
   all of your post-loading javascript as well. Go to your page and check the page
   source. Is the JavaScript there? Is it doing what it’s supposed to be doing?
 *  Thread Starter [kertoon](https://wordpress.org/support/users/kertoon/)
 * (@kertoon)
 * [12 years ago](https://wordpress.org/support/topic/external-javascript-file-not-working-1/#post-4914509)
 * The list of pages with Javascript are all there. That is where I got the whole
   bunch of javascript. I pasted them on the Notepad, minified them before I had
   it uploaded to my root directory.
 * Anyway, a while ago, when I went back to Pingdom Tools I notice I managed to 
   score 1/100 for Combine external Javascript. And now there newly created external
   file is included in the list!
 *  [john_bryan](https://wordpress.org/support/users/john_bryan/)
 * (@john_bryan)
 * [12 years ago](https://wordpress.org/support/topic/external-javascript-file-not-working-1/#post-4914512)
 * I don’t understand. So the problem persists or you have solved it?
 *  Thread Starter [kertoon](https://wordpress.org/support/users/kertoon/)
 * (@kertoon)
 * [12 years ago](https://wordpress.org/support/topic/external-javascript-file-not-working-1/#post-4914513)
 * John Bryan, thank you so much for your prompt reply. It is solved.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘External Javascript File Not Working’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [kertoon](https://wordpress.org/support/users/kertoon/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/external-javascript-file-not-working-1/#post-4914513)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
