반응형

How To Remove Unnecessary Modules in jQuery

http://www.hongkiat.com/blog/jquery-remove-modules/

 

OS X 에서 jquery 설치시 불필요한 모듈 제외하고 설치하기.

 

jQuery is undoubtedly the most popular JavaScript library, (almost) every website on this planet is using it. This affects jQuery to include all the functionalities within the library to cover every instance and possibility.

However, when we work on a simple website, we might only use a few of the functions. Thus, it would be more efficient if we were able to run only that necessary function and not everything other unused function as well. As of version 1.8, jQuery allows us to do this. We are able to exclude some jQuery modules that are not necessary in your project. So, let’s see how we can do it.

First thing first

First, we need to install some tools required to do the job. These tools are Git, Grunt, and Node.js. If you running on OS X, the easiest way to install all these tools is through an OS X Package Manager called Homebrew.

Install Homebrew

So, let’s open up your Terminal and run the following command to install Homebrew. As said, Homebrew will let us install the other mentioned tools more easily.

  1. ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Install Git

After the Homebrew installation completed, run the following command to install Git.

  1. brew install git

Install Node.js

Run the following line to install Node.js

  1. brew install node

Install Grunt

Lastly, we need to install Grunt. Run this command.

  1. npm install -g grunt-cli

Build jQuery

Currently, jQuery allows the following modules to be excluded.

Modules Command Description
Ajax -ajax This specifies the jQuery AJAX API that includes jQuery.ajax(). jQuery.get(), and .load() function
CSS -css This specifies the functions from jQuery CSS Category that includes .addClass(), .css(), and .hasClass().
Deprecated -deprecated This specifies the deprecated modules or functions.
Event Alias -event-alias This specifies the event functions like .click(), .focus(), and .hover().
Dimensions -dimensions This specifies the functions to set CSS dimension. Such functions include .height(), .innerHeight(), and .innerWidth().
Effects -effects This specifes the functions that set animation effects, such as .slideToggle(), .animate() and .fadeIn()
Offset -offset This specifies the functions that retrieve45 coordinates and position. Such funtions include .offset() and .position().

Before we are able to customize the jQuery, we need to clone it from the Github repo by running this command in the Terminal.

  1. git clone git://github.com/jquery/jquery.git

You should then find a new folder named jquery created under your user folder. Navigate to that directory using this command.

  1. cd jquery

Next, we need to install Node dependencies modules to run our project.

  1. npm install

We then build our jQuery by simply running Grunt command (and hit enter)

  1. grunt

It will return the following report, if the operation succeeds.

And as we can see from the report, our jQuery is saved within the dist/ folder. Our jQuery is, at this point, set with all the functionalities, thus the size is quite large, 239kb. The minified version is at 83kb.

Removing Modules

Let’s say, we want to remove the Effect modules from jQuery; we can run this command.

  1. grunt custom:-effects

If we take a look back at the file size, it is now decreased to 220 kb.

To exclude multiple modules, separate each module with a comma, for example:

  1. grunt custom:-effects,-ajax,-deprecated

Final Thought

jQuery can help us manipulate DOM easily, but with 200 kb more at the size, it could affect your website performance. So, by eliminating some unnecessary jQuery modules, your jQuery script will certainly run faster and more efficient. We hope that this little tip would be useful for your next project.

반응형
반응형
사람이 한 번 굳게 결심하면
아무도 그를 막을 수 없다.
그런 사람을 불구자로 만들면
위대한 문인 월터스콧(Walter Scott)이 된다.
감옥에 가두면 영국의 대 소설가 존 버니언(John Bunyan)이 된다.
눈 속에 파묻으면 미국 초대 대통령 조지 워싱턴이 되고,
가난한 가정에서 태어나게 하면 에이브러햄 링컨이 된다.
-샘 E. 로버츠

 

계속되는 샘 로버츠 주장입니다.
“기관차 차고 정비소에 데려다 놓으면
크라이슬러 자동차회사를 세운 월터 크라이슬러가 된다.
남아메리카 무명 오케스트라의 제 2바이올린 주자로 만들면
명지휘자 아르투로 토스카니니(Arturo Toscanini)가 되는 것이다.”
의지가 있는 사람에게는 방법이 따라옵니다.

 

반응형
반응형

엄마는 엄마 모습 그대로였다.
내가 평생동안 알던 엄마. 피부는 기름을 먹인
흑단 같고, 웃을 땐 앞니가 하나 없는 모습이다.
엄마는 많은 일을 겪었고 그로 인해 피부에는
지혜와 고난의 주름이 새겨져 있었다.
이마 주위의 주름은 크나큰 위엄을
느끼게 하며, 그것은 고난이
근심과는 다르다는 것을
말해준다.


- 와리스 디리ㆍ잔 다엠의《사막의 새벽》중에서 -


* 고난과 근심은 다릅니다.
고난은 사람을 강하게 하지만
근심은 사람을 병이 들게 합니다.
특히 엄마의 고난은 자식들을 강인하게 만들지요.
지혜로운 엄마의 주름에 새겨진 고난의 시간이
그 딸로 하여금 세계에 영롱히 빛나는
'흑진주'가 되게 했습니다.

반응형

'생활의 발견 > 아침편지' 카테고리의 다른 글

내 사랑, 안녕!  (0) 2013.07.06
과거  (0) 2013.07.05
젊어지는 식사  (0) 2013.07.03
집중력  (0) 2013.07.02
"여기 있다. 봐라."  (0) 2013.07.01
반응형

가야 할 방향으로 먼저 가봐야 한다. 그래야만 사람들에게 방향을 제시할 수 있다. - 석가모니 -

반응형
반응형
우리 몸은
입으로 들어오는 것을 원재료로
매일 조금씩 신진대사를 하며 다시 태어나고 있다.
따라서 음식과 물이 우리 몸을 새롭게 좋은 몸으로
태어나게 하는 열쇠를 쥐고 있다고 해도 지나친 말이
아니다. 대부분의 사람들은 음식을 먹을 때
영양가나 칼로리에만 신경을 쓰는데,
그러면 노화 현상을 막을 수 없다.
젊게 살고 싶다면
장이 젊어지는 식사를 해야 한다.


- 신야 히로미의《불로장생 탑시크릿》중에서 -


* '장이 젊어지는 식사'.
어찌 보면 해답은 간단합니다.
입이 좋아하는 것만을 먹지 않고
장에 좋은 것들을 찾아서 먹는 것입니다.
바로 바로 확인할 수 있는 것이 대소변입니다.
대소변이 나빠졌거나 변비가 생겼으면 이미 빨간등이
켜졌다는 신호입니다. 먹는 습관부터 바꾸어야
세포가 다시 태어나고 장이 젊어집니다.
장이 젊어지면 몸도 젊어집니다.

 

반응형

'생활의 발견 > 아침편지' 카테고리의 다른 글

과거  (0) 2013.07.05
엄마의 주름  (0) 2013.07.04
집중력  (0) 2013.07.02
"여기 있다. 봐라."  (0) 2013.07.01
삐뚤삐뚤 날아도...  (0) 2013.06.29
반응형
지식은 보잘 것 없으면서 스스로 다 안다고 말하는 자는
반드시 크게 부족한 사람이다.
지난날 다 알지 못하던 것을 깨닫고 나면 반드시
오늘 내가 아는 것이 다 아는 것이 아님을 문득 깨닫게 된다.
스스로 다 안다고 말하는 사람은
오래도록 지식에 진전이 없었던 사람이다.
-조선 후기 홍길주, ‘수여연필(睡餘演筆)’에서

다산 정약용 선생은
“가득차면 반드시 망하고
겸허하면 반드시 존경받는다.
스스로 높다고 여기면 남이 끌어내리고
스스로 낮다고 여기면 남들이 끌어 올려준다.”고
역시 겸손의 중요성을 강조한 바 있습니다.

 

반응형
반응형

Bacon.js

A small functional reactive programming lib for JavaScript.

Link : https://github.com/raimohanska/bacon.js

Turns your event spaghetti into clean and declarative feng shui bacon, by switching from imperative to functional. It's like replacing nested for-loops with functional programming concepts like map and filter. Stop working on individual events and work with event streams instead. Transform your data with map andfilter. Combine your data with merge and combine. Then switch to the heavier weapons and wieldflatMap and combineTemplate like a boss.

It's the _ of Events. Too bad the symbol ~ is not allowed in Javascript.

Here's the stuff.

You can also check out my entertaining (LOL), interactive, solid-ass slideshow.

And remember to give me feedback on the bacon! Let me know if you've used it. Tell me how it worked for you. What's missing? What's wrong? Please contribute!

 

반응형
반응형

 

프로그래밍 얼랭
국내도서
저자 : 조 암스트롱(Joe Armstrong) / 김석준역
출판 : 인사이트 2008.06.12
상세보기

 

오키나와 : Self Travel Guidebook 시리즈

오키나와
국내도서
저자 : 박상용
출판 : 상상출판 2013.03.13
상세보기

 

마이크로소프트웨어 (월간) 7월호
국내도서
저자 : 마소인터렉티브 편집부
출판 : 마소인터렉티브(잡지) 2013.06.28
상세보기

반응형

+ Recent posts