How to embed javascript file in expressionengine template

ExpressionEngine 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>

You can put the javascript code inside a template too. Don’t forget to output content as Gzip for performance.

About these ads

6 thoughts on “How to embed javascript file in expressionengine template

  1. 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.

    • Hi Juan, i don’t know what are you talking about but if you thinks about permission, You should NOT have to make folders world writable(0777), it is ok if you put 0755 or sometime less, it depends.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s