How to embed javascript file in expression engine template
Expression Engine has great features to define various type of templates with rendering proper header information. You can define javascript type template as well. But should we do that? If not, why?
Actually i personaly don’t like to create javascript type template instead i prefer to put the javascript file directly to any folder and include them like below
<script type="text/javascript" src="{site_url}js/mootools1.2.js"></script>
It’s better than javascript type template because templating need extra time to be parse but if you need to put any dynamic content from any weblog, or gallery or anything else, then you may have to put javascript content to EE template.
Macbook Pro 15
Nikon D90
You don’t necessarily need to use {site_url} as long as you path from the root.. using /js/jswhatever.js.
NOTE: ExpressionEngine, not Expression Engine.
I also prefer to keep css files outside of EE, but that’s a personal preference.
Sue Crocker
June 23, 2009 at 10:44 am
I always prefer to put the full url path instead of relative. Thanks for the correction. Yes, i like to keep the css files outside the EE, in fact i’ve a post
, see here
http://kodegeek.wordpress.com/2009/06/13/includeembed-stylesheet-properly-expression-engine/
kodegeek
June 23, 2009 at 11:18 am