I think the answer is to make namespaces ubiquitous and trivial to add. See this project:
http://github.com/mckoss/namespace. Adding this tiny library, you can then use CommonJS-style exports and require() to reference across namespaces. Now every one of your namespaces sits quietly inside a SINGLE 'namespace' global. namespace.module('com.mydomain.mymodule', function (exports, require) { ... }); On Apr 6, 5:47 am, ben <[email protected]> wrote: > No one likes globals in javascript. > Therefore we group our variables and function in a namespace or wrap > all our code in a anonymous function to prevent global. > However there are certain situation that we might need to use global. > For example when our project is growing bigger and we have to split > our code into modules and save them in different files. > Therefore I wrote this jQuery plugin call jQuery Secret to solve it. > > documentationhttp://dreamerslab.com/blog/en/hide-javascript-global-objects-with-jq... > > source codehttps://github.com/dreamerslab/jquery.secret > > --------------------------------------------------------------------------- > -------------------------------------------------- > example code > > Store data > > // 'val' can be a string, integer, hash table, array, object > $.secret( 'in', 'secretName', val ); > > // or a function > $.secret( 'in', 'secretName', function( arg1, arg2, arg3 ){ > // do something here > }); > > Use data; you can even use it in different files. > > var lang = $.secret( 'out', 'lang' ); > > Call out a function > > $.secret( 'call', 'secretName', [ arg1, arg2, arg3 ]); > // or > $.secret( 'call', 'secretName', arg ); > > Clear data > > $.secret( 'clear', 'lang' ); > > --------------------------------------------------------------------------- > -------------------------------------------------- > > Actually it's got nothing to do with jquery > I just did not want to create another namespace > and jquery is popular so I wrap the code under jquery's namespace > > If someone does try it out please give me some feedbacks > > thanks a lot > > ben :) -- 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]
