AnsweredAssumed Answered

Tidying my JS's

Question asked by eolith on Jul 2, 2009

I'm currently developing a set of web scripts and there's a lot of common (server) Javascript code among them. So,

1) How can I "import" a JS file being sure that it has'n been imported before by one of the other JS imports? For example, if I have a "constants.js", or "utils.js", it could happen to having the same function declared 2 times in the same JS via several different imports. Any idea what's the best solution??

2) What if I keep all common code into a big, single JS?? Then I only have to write an "import" line on each web script js. But I don't know if the performance could be affected by this solution…

Thank you for your help :)