# If your javascript doesn't execute, but instead just gets displayed on the browser

**URL:** <https://www.ruby-forum.com/t/if-your-javascript-doesnt-execute-but-instead-just-gets-displayed-on-the-browser/187105>\
**Category:** Rails\
**Created:** [April 17, 2010, 5:59am UTC](https://www.ruby-forum.com/t/if-your-javascript-doesnt-execute-but-instead-just-gets-displayed-on-the-browser/187105 "2010-04-17T05:59:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mstoth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/54ee81/32.png) [@mstoth](https://www.ruby-forum.com/u/mstoth)\
**Post date:** [April 17, 2010, 5:59am UTC](https://www.ruby-forum.com/t/if-your-javascript-doesnt-execute-but-instead-just-gets-displayed-on-the-browser/187105/1 "2010-04-17T05:59:08Z")

</div>

OK, I’ve been struggling for days trying to understand why my  
javascript is just being displayed on the browser rather than  
executed. I have found out the placement of the  
javascript\_include\_tag was my problem.

I have other javascript code in my header and if I place the  
javascript\_include\_tag before my other javascript code I only see the  
javascript I’m trying to execute displayed in my browser. If I put it  
after my other code, it gets executed.

I can not see what it is about my other javascript code that causes it  
to matter. it only consists of function definitions and quite  
honestly after wasting almost a week on this I don’t want to spend  
more time to figure that out. So if this happens to anyone else  
hopefully the will see this and make sure your  
javascript\_include\_tag :defaults is not being somehow ruined by having  
other javascript code after it.

If anyone has some insight into this I’d love to hear it.

-Michael

---

<div class="post-metadata">

**Author:** ![mstoth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/54ee81/32.png) [@mstoth](https://www.ruby-forum.com/u/mstoth)\
**Post date:** [April 17, 2010, 10:09am UTC](https://www.ruby-forum.com/t/if-your-javascript-doesnt-execute-but-instead-just-gets-displayed-on-the-browser/187105/2 "2010-04-17T10:09:02Z")

</div>

On 17 April 2010 04:57, mstoth [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I can not see what it is about my other javascript code that causes it  
> to matter. it only consists of function definitions and quite  
> honestly after wasting almost a week on this I don’t want to spend  
> more time to figure that out. So if this happens to anyone else  
> hopefully the will see this and make sure your  
> javascript\_include\_tag :defaults is not being somehow ruined by having  
> other javascript code after it.

Have you tried pasting the html of the page into the w3c html  
validator (google will find it)? Sometimes strange problems can be  
seen as the browser attempts to make sense of invalid html.

Colin
