[Solved] Using Javascripts

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Locked
Muzzy

[Solved] Using Javascripts

Post by Muzzy »

Hi People.

I know this is a dumb question, but...

I am about to revamp my old CMSMS site and I want to use several Javascripts to call items including my own image gallery.
Should I put the Javascript files in Global content blocks or is it best done another way.

Thanks.
Mike.
Last edited by Muzzy on Sat Apr 21, 2007 3:42 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Using Javascripts

Post by calguy1000 »

GCB's work great.  especially if they're going to be re-used across templates and/or pages.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Pierre M.

Re: Using Javascripts

Post by Pierre M. »

As a webmaster, you are aware that Firefoxers may install NoScript ?
https://addons.mozilla.org/fr/firefox/addon/722
...and that Konqueror users may disable JS too ?
But I think your GCB idea is better than messing inside HTML.
Pierre M.
bladenet

Re: Using Javascripts

Post by bladenet »

the javascript can be put in the template or in a global content block. just don't forget the {literal}{/literal} tags.

If you put the javascript in the template, you'll have faster loading because one global content block is one mysql query.
If you put it in gcb you'll have a cleaner template and easyer editing later.

Hope that answers your question.
Muzzy

Re: Using Javascripts

Post by Muzzy »

Hi Guys.

Many thanks for the speedy reply and excellent guidance.

Thanks.
Mike.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Using Javascripts

Post by Dee »

Personally I prefer using external javascript files. This way they are cached by the browser so they can be reused on other pages without data transfer/db queries. Also, in my experience the Javascript on a site is seldom changed once it is written.

Code: Select all

<__script__ type="text/javascript" src="/path/to/cmsmadesimple/js/thescript.js"></__script>
Regards,
D
Muzzy

Re: Using Javascripts

Post by Muzzy »

Hi Dee.

Thanks. So basically you are saying use the Javascripts called from within the page to a seperate folder on my server, much as I do for my old html sites before css/xhtml.

Bless you.
Mike.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Using Javascripts

Post by Dee »

Indeed, in XHTML script elements are wrapped within a CDATA marked section or put in external scripts if they use or --.
There are no differences with HTML4.0.1 in how you can specify a src URI to include an external script.

Regards,
D
Locked

Return to “Layout and Design (CSS & HTML)”