Skip to content

Instantly share code, notes, and snippets.

@cdcabrera
Created March 19, 2013 01:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Basic structure related to plugin and application layout. Originally this was devised based on how the jQuery team recommend you create plugins. I simply modified it to encompass application related JS. Generally we place this either directly at the bottom, or within a JS file referenced at the bottom of the page.
(function(window,$,undefined){
if(typeof $ == 'boolean' && $ == true)
{
return;
}
//-- basic settings using descriptive prefixes
var _settings =
{
url_someurl : 'someurl.file',
obj_somedesc : $('#someselector'),
link_somelink : $('a#somelinkselector'),
class_someclass : 'someclass'
};
//-- internal
var _data =
{
mydata : null
};
$(document).ready(function()
{
//-- do something
_somefunction();
});
function _somefunction()
{
//-- local references
var url_someurl = _settings.url_someurl,
obj_somedesc = _settings.obj_somedesc,
link_somelink = _settings.link_somelink,
class_someclass = _settings.class_someclass;
//-- doing stuff
}
})(this,(typeof jQuery == 'undefined' || jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment