Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created February 14, 2010 23:18
Show Gist options
  • Save cowboy/304332 to your computer and use it in GitHub Desktop.
Save cowboy/304332 to your computer and use it in GitHub Desktop.
################################################################
name: jQuery plugin closure
tab trigger: jqp
scope selector: source.js
code:
(function(\$${2:,window}${3:,undefined}){
'$:nomunge'; // Used by YUI compressor.
${0:// OMG LETS MAKE A PLUGIN!!}
})(jQuery${1:,this});
################################################################
name: loopy
tab trigger: loopy
scope selector: source.js
code:
(function loopy(){
${0:// cool stuff here}
setTimeout( loopy, ${1:250} );
})();
################################################################
name: instant-invoke anonymous function
tab trigger: fnow
scope selector: source.js
code:
(function($2){
${0:// cool stuff here}
})($1);
################################################################
name: html 5 document
tab trigger: html
scope selector:
code:
<!DOCTYPE HTML>
<html lang="en-US" class="no-js">
<head>
<script type="text/javascript">(function(h,a){h[a]=h[a].replace(/\bno-js\b/,'js')})(document.documentElement,'className')</script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>$1</title>
</head>
<body>
$0
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment