Skip to content

Instantly share code, notes, and snippets.

@dirq
Last active August 29, 2015 14:15
Show Gist options
  • Save dirq/d4003c492a4470ba0edf to your computer and use it in GitHub Desktop.
Save dirq/d4003c492a4470ba0edf to your computer and use it in GitHub Desktop.
JavaScript Closure IFFY Module
var app = (function ()
{
'use strict';
var self = {},
debug = true;
function log(msg)
{
if (debug && console && console.log)
{
console.log(msg);
}
}
self.init = function ()
{
log('init');
};
return self;
}());
//plan JS load
if (document.addEventListener)
{
//For modern browsers:
document.addEventListener('DOMContentLoaded', app.init, false);
}
else if (document.attachEvent)
{
//For IE:
document.attachEvent('onreadystatechange', app.init);
}
//jquery load
//$(app.init);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment