namespacing large javascript like jquery
Posted
by
frenchie
on Stack Overflow
See other posts from Stack Overflow
or by frenchie
Published on 2012-04-11T23:25:24Z
Indexed on
2012/04/11
23:28 UTC
Read the original article
Hit count: 208
JavaScript
I have a very large javascript file: it's over 9,000 lines. The code looks like this:
var GlobalVar1 = "";
var GlobalVar2 = null;
function A() {...}
function B(SomeParameter) {...}
I'm using the google compiler and the global variables and functions get renamed a,b,c... and there's a good change that there might be some collision later with some outside code.
What I want to do is have my code organized like the jquery library where everything is accessible with $. Is there a way to namespace my code so that everything is behind a # character for example.
I'd like to have this to call my code:
#.GlobalVar
#.functionA(SomeParameter)
How can I do this?
Thanks.
© Stack Overflow or respective owner