Page 1 of 1
[Solved] Using Javascripts
Posted: Wed Apr 18, 2007 7:28 pm
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.
Re: Using Javascripts
Posted: Wed Apr 18, 2007 7:38 pm
by calguy1000
GCB's work great. especially if they're going to be re-used across templates and/or pages.
Re: Using Javascripts
Posted: Wed Apr 18, 2007 7:39 pm
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.
Re: Using Javascripts
Posted: Wed Apr 18, 2007 7:40 pm
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.
Re: Using Javascripts
Posted: Wed Apr 18, 2007 7:50 pm
by Muzzy
Hi Guys.
Many thanks for the speedy reply and excellent guidance.
Thanks.
Mike.
Re: Using Javascripts
Posted: Wed Apr 18, 2007 7:56 pm
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
Re: Using Javascripts
Posted: Wed Apr 18, 2007 8:12 pm
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.
Re: Using Javascripts
Posted: Wed Apr 18, 2007 9:43 pm
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