Click to See Complete Forum and Search --> : Best way to include Javscript only on certain page


damon2003
06-10-2011, 07:47 AM
Hi,

I am building a site in .net 4.0. Whats a good way to include some Javascript only on the homepage or certain other pages?

<script type="text/javascript">

....</script>

ssystems
06-13-2011, 02:54 PM
I usually use content place holders for that

damon2003
06-14-2011, 04:27 AM
Should it be ok to include Javascript includes anywhere on the page, even at the bottom? Does it make any difference?

ssystems
06-14-2011, 11:36 PM
This is still a matter of debate last time I checked.

So far there is two prominent answers to this.

1. Place all javascript at the bottom of the page because how the way the pages loads. Look at this (http://developer.yahoo.com/performance/rules.html#js_bottom)

2. Is to place the script on the header since this ensure that the script is loaded before you call it.

Consequently, it's still a matter of how your pages are set-up. If you're scripts doesn't block parallel loading I would place it on the header otherwise place it at the very end to ensure faster loading