Skip to content

Instantly share code, notes, and snippets.

@safe1981
Created March 15, 2012 05:30
Show Gist options
  • Save safe1981/2042160 to your computer and use it in GitHub Desktop.
Save safe1981/2042160 to your computer and use it in GitHub Desktop.
javascript: jquery plugin작성 시에 기본으로 적용하는 초기 구조
//플러그인 작성기법
//window, document와 같은 전역변수를 굳이 넘기는 이유
//1. Local변수에 캐싱하여 효과를 높이는 효과
//2. 코드 압축 수행시 효과적으로 압축가능 window=>a. document=>b 등
//undefined를 마지막에 쓰는 이유, 악의적으로 undefined변조가능
(function( $, window, document, undefined ) {
$.fn.queryTwitter = function() {
console.log("test");
};
})( jQuery, window, document );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment