I am using similar approach like you in my current project but like the others
it depends on project . I am putting all javascript code and page specific code
in myproject.js and in this file I am using a Javascript object to page
specific initialization or objects like this.
Application.Pages = {
UserMovieList: {
init: function() {
//page specific code
}
},
MovieListEdit: {
init: function() {
//....
}
}
}
and in a page I am calling page specific functions like this
<script>
Application.Pages.MovieListEdit.init();
</script>
That's a pretty cool way. Thanks
On Thu, Jan 27, 2011 at 11:08 AM, Marc Palau
<[email protected]<mailto:[email protected]>> wrote:
We use a javascript provider that merge all js files with a PHP method and then
cache it into a file to boost the loads. One file, one petition.
<code>
include_once('/path/class_JS.php');
$jsclass = new JSClass();
?>
<DOCTYPE>
<html>
<head><title></title>
<?
$jsclass->initHeadJS('jquery','cufon','myriad','base',true); //last
argument is for cache it or not
$jsclass->initHeadIE(); //prints all bulkshit for IE
$jsclass->initFuncJS('Base.init','Base.index.init'); //print the <script
tag>. I use this method to easily change the onloadmethod.
?>
...
</code>
Then with apache we gzip the generated file.
cheers
Marc
En/na Smith, Garren ha escrit:
Hi All,
I want to know what is the best practice or how everyone organises there
javascript files. I initially use to just embed all my js in the html file but
that gets messy quick. Now I create an application.js file that I reference on
all pages. This is slightly better but often there is code only specific to a
page. Do you guys embed that in the html page?
It seems everyone is trying to do unobtrusive javascript I'm just not sure how
to achieve that.
Any help would be great.
Thanks
Garren
________________________________
This e-mail is subject to a disclaimer, available at
http://www.firstrand.co.za/content/376/disclaimer/ --
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]<mailto:[email protected]>
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]<mailto:jsmentors%[email protected]>
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]<mailto:[email protected]>
This e-mail is subject to a disclaimer, available at
http://www.firstrand.co.za/content/376/disclaimer/
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]