views:

108

answers:

1

Hi there,

I am trying to reorganize my javascript into JS files and clear out my js from my html... The way i see if is the following.... I would really like some input or any documentation/information confirming my plans - a little uncertain.

Basically if i have a Home.htm file then i will have a home.js file also, notice they are named the same. THe home.js will be like the bootstrapper for that page and will assign events (onclick etc)...

I was planning on doing this with all files i.e. login.htm > login.js ...

I was also thinking about have a global.js file which will be included in EVERY page that contains items that are needed in every file..

I also plan on having other js files which i plan on producing in a namespace so that my bootstrapper files can call classes in that namespace to do things like date manipulation etc.. I know JS is not a true OOP language but i have some helper js which allow to create namespaces and better class structures.

Does anyone have a better idea? Am completely going in the wrong or right direction?

I would really like some input, i am trying to separate all my js into separate files but i don't want to repeat myself so i thought of creating those bootstrapper files to take care of everything for the page..

Thanks

+1  A: 

Depending on how you go about it, I think the idea itself is quite reasonable. Namespacing your JS code in an OOP-like fashion is a good idea, and many libraries such as YUI and Dojo already do it.

Jani Hartikainen
thanks for the confirmation ...
mark smith