Instantly share code, notes, and snippets.

Embed
What would you like to do?
Handy JavaScript snippets for Visual Studio
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Immediately Invoked Function Expression</Title>
<Author>Stephen James (@stephenhjames)</Author>
<Shortcut>iife</Shortcut>
<Description>Code snippet for an Immediately-Invoked Function Expression</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="JavaScript"><![CDATA[(function() {
$selected$$end$
}());]]></Code>
</Snippet>
</CodeSnippet>
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>jQuery document.ready wrapping function</Title>
<Author>Stephen James (@stephenhjames)</Author>
<Shortcut>jqready</Shortcut>
<Description>Code snippet for creating a jQuery document.ready wrapping function</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
</Declarations>
<Code Language="JavaScript"><![CDATA[$$(function () {
$selected$$end$
});]]></Code>
</Snippet>
</CodeSnippet>
<CodeSnippet Format="1.1.0"
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>Revealing Module IIFE</Title>
<Author>Stephen James (@stephenhjames)</Author>
<Shortcut>rvm</Shortcut>
<Description>Code snippet for creating a revealing module immediately
invoked function expression</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>moduleName</ID>
<ToolTip>Module Name</ToolTip>
<Default>myModule</Default>
</Literal>
</Declarations>
<Code Language="JavaScript"><![CDATA[var $moduleName$ = (function () {
$selected$$end$
return {
}
}());]]></Code>
</Snippet>
</CodeSnippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment