반응형
반응형

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.

반응형
반응형

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!

 

반응형
반응형

A JavaScript standard library based on the Ruby core-lib

RubyJS is a JavaScript implementation of all methods from Ruby classes like Array, String, Numbers, Time and more.

 

http://rubyjs.org/

 

 

100% JavaScript

RubyJS is built on top of JavaScript. It runs in all browsers. No additional tools needed.

Works like Ruby

Easily port code from Ruby to JavaScript. Become productive in JavaScript in hours. Fully tested with rubyspec.

Fast and small

20 kilobytes minified and gzipped. It is as fast or faster than comparable libraries.


Utility belt or OO

Use RubyJS like a utility belt, transforming arrays, string and continue with native objects. Or use the fully-fledged RubyJS objects and make use of their mutator (aka bang) methods.

All-in-one Library

String, Array, Time, Numbers, Range, and more. RubyJS gives you the power of multiple 3rd party libraries, with one coherent API. So you only have to learn, manage and update one.

Ruby Features

Block arguments, destructive (bang-) methods, duck-typing, special variables, mixins.

 

 

Getting Started with RubyJS

 :   http://rubyjs.org/getting-started.html

 

 

반응형
반응형

Front-End 개발에 대한 자료

A huge list of frontend development resources I collected over time. Pull requests are welcome. Website coming soon.

 

https://github.com/dypsilon/frontend-dev-bookmarks

 

Frontend Development

반응형
반응형

Flippant.js — A tiny library for flipping things over

 

http://labs.mintchaos.com/flippant.js/

 

 

반응형
반응형

cujoJS — Build modular, maintainable web apps

cujojs

Homepage: http://cujojs.com/
GitHub: https://github.com/cujojs
Twitter: http://twitter.com/cujojs

 

 

cujojs's Repositorieshttps://github.com/cujojs/repositories

 

 

RESTful HTTP client for JavaScript

 : https://github.com/cujojs/rest 

반응형

+ Recent posts