Skip to content

Instantly share code, notes, and snippets.

@cdcabrera
Created March 19, 2013 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdcabrera/335b82b95afd3f43f133 to your computer and use it in GitHub Desktop.
Save cdcabrera/335b82b95afd3f43f133 to your computer and use it in GitHub Desktop.
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