SlideShare une entreprise Scribd logo
1  sur  3
Télécharger pour lire hors ligne
Nguyễn Ngọc Dũng
https://nndung179.wordpress.com Page 1
Compressed JS with NodeJS & GruntJS
This tutorial will show you how to use grunt to compress js files from your
project.
1. Install node js
2. Install Grunt CLI globally
npm install -g grunt-cli
3. For example, I have this structure of web:
4. At folder JSCompressed create files:
a. package.json
{
"name" : "menory",
"title" : "test",
"version" : "1.0.0",
"devDependencies": {
"grunt": "0.4.1",
"grunt-contrib-concat": "0.1.3",
"grunt-contrib-cssmin" : "0.6.1",
"grunt-contrib-watch" : "0.5.3",
"grunt-contrib-uglify" : "0.2.0"
}
}
5. Open cmd
a. + cd to JSCompressed folder
b. Execute: npm install
6. Configuration Gruntfile.js
a. Gruntfile.js
Nguyễn Ngọc Dũng
https://nndung179.wordpress.com Page 2
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
js: {
src: [
'lib/jquery.js',
'lib/bootstrap.min.js'
],
dest: 'combined.js'
}
},
uglify: {
js: {
files: {
'combined.js':
['combined.js']
}
}
},
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['concat:js',
'uglify:js']);
};
b. Explaination Gruntfile.js
concat: {
js: {
src: [
'lib/jquery.js',
'lib/bootstrap.min.js'
],
dest: 'combined.js'
}
},
Nguyễn Ngọc Dũng
https://nndung179.wordpress.com Page 3
This block of codes means: you will copy all source code fron js files into
1 file call combined.js (A)
Note: at src attribute, you must place js files with the order of
dependency.
uglify: {
js: {
files: {
'combined.js': ['combined.js']
}
}
},
This block of codes means: from combined.js (A), you will compress you
js here.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
Load all module you have installed at step 5
grunt.registerTask('default', ['concat:js',
'uglify:js']);
This block of codes is very important, It means that after you do all
configurations. You will register as task for Grunt to execute all tasks
you have config above.
7. Result
The result of this procress will be a file with jquery & bootstrap in one
file under compressed format.

Contenu connexe

Tendances

Nightwatch.js (vodQA Shots - Pune 2017)
Nightwatch.js (vodQA Shots - Pune 2017)Nightwatch.js (vodQA Shots - Pune 2017)
Nightwatch.js (vodQA Shots - Pune 2017)Smriti Tuteja
 
Building a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDBBuilding a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDBVivochaLabs
 
進階使用Nodejs 淺談no sql(mongodb)
進階使用Nodejs 淺談no sql(mongodb)進階使用Nodejs 淺談no sql(mongodb)
進階使用Nodejs 淺談no sql(mongodb)Simon Su
 
virtualization course content
virtualization course contentvirtualization course content
virtualization course contentsadikshya sharma
 
What is Node.js
What is Node.jsWhat is Node.js
What is Node.jsBrian Best
 
Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Fred Chien
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Devang Garach
 
Gerenciando múltiplas versões do PostgreSQL com pgvm
Gerenciando múltiplas versões do PostgreSQL com pgvmGerenciando múltiplas versões do PostgreSQL com pgvm
Gerenciando múltiplas versões do PostgreSQL com pgvmDickson S. Guedes
 
S&T What I know about Node 110817
S&T What I know about Node 110817S&T What I know about Node 110817
S&T What I know about Node 110817Dan Dineen
 
Quick Introduction to Node.js
Quick Introduction to Node.jsQuick Introduction to Node.js
Quick Introduction to Node.jsNaing Lin Aung
 
Web technologies for desktop development
Web technologies for desktop developmentWeb technologies for desktop development
Web technologies for desktop developmentDarko Kukovec
 
Capodieci - Proof of... what?
Capodieci - Proof of... what?Capodieci - Proof of... what?
Capodieci - Proof of... what?Roberto Capodieci
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The BeginningAxilis
 

Tendances (20)

Nightwatch.js (vodQA Shots - Pune 2017)
Nightwatch.js (vodQA Shots - Pune 2017)Nightwatch.js (vodQA Shots - Pune 2017)
Nightwatch.js (vodQA Shots - Pune 2017)
 
Building a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDBBuilding a REST API with Node.js and MongoDB
Building a REST API with Node.js and MongoDB
 
NodeJS
NodeJSNodeJS
NodeJS
 
進階使用Nodejs 淺談no sql(mongodb)
進階使用Nodejs 淺談no sql(mongodb)進階使用Nodejs 淺談no sql(mongodb)
進階使用Nodejs 淺談no sql(mongodb)
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
virtualization course content
virtualization course contentvirtualization course content
virtualization course content
 
What is Node.js
What is Node.jsWhat is Node.js
What is Node.js
 
Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
 
Gerenciando múltiplas versões do PostgreSQL com pgvm
Gerenciando múltiplas versões do PostgreSQL com pgvmGerenciando múltiplas versões do PostgreSQL com pgvm
Gerenciando múltiplas versões do PostgreSQL com pgvm
 
S&T What I know about Node 110817
S&T What I know about Node 110817S&T What I know about Node 110817
S&T What I know about Node 110817
 
Quick Introduction to Node.js
Quick Introduction to Node.jsQuick Introduction to Node.js
Quick Introduction to Node.js
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Cscript exe
Cscript exeCscript exe
Cscript exe
 
Deep dive-oz
Deep dive-ozDeep dive-oz
Deep dive-oz
 
Web technologies for desktop development
Web technologies for desktop developmentWeb technologies for desktop development
Web technologies for desktop development
 
Capodieci - Proof of... what?
Capodieci - Proof of... what?Capodieci - Proof of... what?
Capodieci - Proof of... what?
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The Beginning
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 

En vedette

Duality in AdS/CFT, Chicago 7 Nov. 2014
Duality in AdS/CFT, Chicago 7 Nov. 2014Duality in AdS/CFT, Chicago 7 Nov. 2014
Duality in AdS/CFT, Chicago 7 Nov. 2014Sebastian De Haro
 
Strings, Quantum Gravity, and Reduction
Strings, Quantum Gravity, and ReductionStrings, Quantum Gravity, and Reduction
Strings, Quantum Gravity, and ReductionSebastian De Haro
 
Стандарт технического сопровождения LinuxWizard
Стандарт технического сопровождения LinuxWizardСтандарт технического сопровождения LinuxWizard
Стандарт технического сопровождения LinuxWizardLWandWs
 
3 phelan ifa prague 2012-al
3 phelan ifa prague 2012-al3 phelan ifa prague 2012-al
3 phelan ifa prague 2012-alifa2012_2
 
1 judd-ifa 2012 pp(3)
1 judd-ifa 2012 pp(3)1 judd-ifa 2012 pp(3)
1 judd-ifa 2012 pp(3)ifa2012_2
 
Somo iOS 9 workshop
Somo iOS 9 workshopSomo iOS 9 workshop
Somo iOS 9 workshopSomo
 
Ophelia and gertrude
Ophelia and gertrudeOphelia and gertrude
Ophelia and gertrudebhavnabaraiya
 
INTEGRATE Chicago - Joseph Truncale
INTEGRATE Chicago - Joseph TruncaleINTEGRATE Chicago - Joseph Truncale
INTEGRATE Chicago - Joseph TruncaleIMCWVU
 
Melt consulting
Melt consultingMelt consulting
Melt consultingmatquittre
 
Πρόσκληση εκπαιδευτών
Πρόσκληση εκπαιδευτώνΠρόσκληση εκπαιδευτών
Πρόσκληση εκπαιδευτώνiekkastorias
 
Laboratorio excel
Laboratorio excelLaboratorio excel
Laboratorio exceljosetjitt
 
Liberal Arts Conference - Core Texts in the Sciences
Liberal Arts Conference - Core Texts in the SciencesLiberal Arts Conference - Core Texts in the Sciences
Liberal Arts Conference - Core Texts in the SciencesSebastian De Haro
 

En vedette (20)

Duality in AdS/CFT, Chicago 7 Nov. 2014
Duality in AdS/CFT, Chicago 7 Nov. 2014Duality in AdS/CFT, Chicago 7 Nov. 2014
Duality in AdS/CFT, Chicago 7 Nov. 2014
 
Strings, Quantum Gravity, and Reduction
Strings, Quantum Gravity, and ReductionStrings, Quantum Gravity, and Reduction
Strings, Quantum Gravity, and Reduction
 
Стандарт технического сопровождения LinuxWizard
Стандарт технического сопровождения LinuxWizardСтандарт технического сопровождения LinuxWizard
Стандарт технического сопровождения LinuxWizard
 
3 phelan ifa prague 2012-al
3 phelan ifa prague 2012-al3 phelan ifa prague 2012-al
3 phelan ifa prague 2012-al
 
1 judd-ifa 2012 pp(3)
1 judd-ifa 2012 pp(3)1 judd-ifa 2012 pp(3)
1 judd-ifa 2012 pp(3)
 
5 Our Cosmic Origins
5 Our Cosmic Origins5 Our Cosmic Origins
5 Our Cosmic Origins
 
Estevez amb to_mex
Estevez amb to_mexEstevez amb to_mex
Estevez amb to_mex
 
Somo iOS 9 workshop
Somo iOS 9 workshopSomo iOS 9 workshop
Somo iOS 9 workshop
 
Jeimy lucero gomez1
Jeimy lucero gomez1Jeimy lucero gomez1
Jeimy lucero gomez1
 
Ophelia and gertrude
Ophelia and gertrudeOphelia and gertrude
Ophelia and gertrude
 
INTEGRATE Chicago - Joseph Truncale
INTEGRATE Chicago - Joseph TruncaleINTEGRATE Chicago - Joseph Truncale
INTEGRATE Chicago - Joseph Truncale
 
Melt consulting
Melt consultingMelt consulting
Melt consulting
 
CREA Black Holes
CREA Black HolesCREA Black Holes
CREA Black Holes
 
AVAILABILITY
AVAILABILITYAVAILABILITY
AVAILABILITY
 
Kevingrazon
KevingrazonKevingrazon
Kevingrazon
 
Jenifer bohorquez 2
Jenifer bohorquez 2Jenifer bohorquez 2
Jenifer bohorquez 2
 
Miller Arenas 2
Miller  Arenas 2Miller  Arenas 2
Miller Arenas 2
 
Πρόσκληση εκπαιδευτών
Πρόσκληση εκπαιδευτώνΠρόσκληση εκπαιδευτών
Πρόσκληση εκπαιδευτών
 
Laboratorio excel
Laboratorio excelLaboratorio excel
Laboratorio excel
 
Liberal Arts Conference - Core Texts in the Sciences
Liberal Arts Conference - Core Texts in the SciencesLiberal Arts Conference - Core Texts in the Sciences
Liberal Arts Conference - Core Texts in the Sciences
 

Similaire à Compressed js with NodeJS & GruntJS

Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Future Insights
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end WorkflowPagepro
 
Modern Development Tools
Modern Development ToolsModern Development Tools
Modern Development ToolsYe Maw
 
Automating Front-End Workflow
Automating Front-End WorkflowAutomating Front-End Workflow
Automating Front-End WorkflowDimitris Tsironis
 
Grunt understanding
Grunt understandingGrunt understanding
Grunt understandingKhalid Khan
 
Node js training (1)
Node js training (1)Node js training (1)
Node js training (1)Ashish Gupta
 
Introduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentIntroduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentJames Bundey
 
Introduction to Express and Grunt
Introduction to Express and GruntIntroduction to Express and Grunt
Introduction to Express and GruntPeter deHaan
 
Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Dirk Ginader
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppEdureka!
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsVisual Engineering
 
Prosit google-cloud
Prosit google-cloudProsit google-cloud
Prosit google-cloudUC Davis
 
Get Grulping with JavaScript Task Runners
Get Grulping with JavaScript Task RunnersGet Grulping with JavaScript Task Runners
Get Grulping with JavaScript Task RunnersMatt Gifford
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JSJacob Nelson
 
Get Gulping with Javascript Task Runners
Get Gulping with Javascript Task RunnersGet Gulping with Javascript Task Runners
Get Gulping with Javascript Task RunnersColdFusionConference
 

Similaire à Compressed js with NodeJS & GruntJS (20)

Using GruntJS
Using GruntJSUsing GruntJS
Using GruntJS
 
Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)
 
Grunt All Day
Grunt All DayGrunt All Day
Grunt All Day
 
GruntJS + Wordpress
GruntJS + WordpressGruntJS + Wordpress
GruntJS + Wordpress
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end Workflow
 
Modern Development Tools
Modern Development ToolsModern Development Tools
Modern Development Tools
 
Automating Front-End Workflow
Automating Front-End WorkflowAutomating Front-End Workflow
Automating Front-End Workflow
 
Grunt understanding
Grunt understandingGrunt understanding
Grunt understanding
 
Node js training (1)
Node js training (1)Node js training (1)
Node js training (1)
 
Introduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentIntroduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme development
 
Introduction to Express and Grunt
Introduction to Express and GruntIntroduction to Express and Grunt
Introduction to Express and Grunt
 
Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
 
Grunt
GruntGrunt
Grunt
 
Workshop 3: JavaScript build tools
Workshop 3: JavaScript build toolsWorkshop 3: JavaScript build tools
Workshop 3: JavaScript build tools
 
Prosit google-cloud
Prosit google-cloudProsit google-cloud
Prosit google-cloud
 
Get Grulping with JavaScript Task Runners
Get Grulping with JavaScript Task RunnersGet Grulping with JavaScript Task Runners
Get Grulping with JavaScript Task Runners
 
Front end development gurant
Front end development gurantFront end development gurant
Front end development gurant
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
 
Get Gulping with Javascript Task Runners
Get Gulping with Javascript Task RunnersGet Gulping with Javascript Task Runners
Get Gulping with Javascript Task Runners
 

Plus de David Nguyen

ACOMP_2014_submission_70
ACOMP_2014_submission_70ACOMP_2014_submission_70
ACOMP_2014_submission_70David Nguyen
 
jQuery Super Basic
jQuery Super BasicjQuery Super Basic
jQuery Super BasicDavid Nguyen
 
Javascript native OOP - 3 layers
Javascript native OOP - 3 layers Javascript native OOP - 3 layers
Javascript native OOP - 3 layers David Nguyen
 
MVC4 – knockout.js – bootstrap – step by step – part 1
MVC4 – knockout.js – bootstrap – step by step – part 1MVC4 – knockout.js – bootstrap – step by step – part 1
MVC4 – knockout.js – bootstrap – step by step – part 1David Nguyen
 
Chứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao hChứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao hDavid Nguyen
 
Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8 Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8 David Nguyen
 
KTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng QuátKTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng QuátDavid Nguyen
 
KTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngKTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngDavid Nguyen
 

Plus de David Nguyen (13)

ACOMP_2014_submission_70
ACOMP_2014_submission_70ACOMP_2014_submission_70
ACOMP_2014_submission_70
 
jQuery Super Basic
jQuery Super BasicjQuery Super Basic
jQuery Super Basic
 
Javascript native OOP - 3 layers
Javascript native OOP - 3 layers Javascript native OOP - 3 layers
Javascript native OOP - 3 layers
 
MVC4 – knockout.js – bootstrap – step by step – part 1
MVC4 – knockout.js – bootstrap – step by step – part 1MVC4 – knockout.js – bootstrap – step by step – part 1
MVC4 – knockout.js – bootstrap – step by step – part 1
 
Facebook API
Facebook APIFacebook API
Facebook API
 
Quick sort
Quick sortQuick sort
Quick sort
 
Merge sort
Merge sortMerge sort
Merge sort
 
Heap Sort
Heap SortHeap Sort
Heap Sort
 
Chứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao hChứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao h
 
Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8 Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8
 
KTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng QuátKTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng Quát
 
KTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngKTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm Động
 
Mô Hình MVC 3.0
Mô Hình MVC 3.0Mô Hình MVC 3.0
Mô Hình MVC 3.0
 

Dernier

Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Dernier (20)

young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

Compressed js with NodeJS & GruntJS

  • 1. Nguyễn Ngọc Dũng https://nndung179.wordpress.com Page 1 Compressed JS with NodeJS & GruntJS This tutorial will show you how to use grunt to compress js files from your project. 1. Install node js 2. Install Grunt CLI globally npm install -g grunt-cli 3. For example, I have this structure of web: 4. At folder JSCompressed create files: a. package.json { "name" : "menory", "title" : "test", "version" : "1.0.0", "devDependencies": { "grunt": "0.4.1", "grunt-contrib-concat": "0.1.3", "grunt-contrib-cssmin" : "0.6.1", "grunt-contrib-watch" : "0.5.3", "grunt-contrib-uglify" : "0.2.0" } } 5. Open cmd a. + cd to JSCompressed folder b. Execute: npm install 6. Configuration Gruntfile.js a. Gruntfile.js
  • 2. Nguyễn Ngọc Dũng https://nndung179.wordpress.com Page 2 module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), concat: { js: { src: [ 'lib/jquery.js', 'lib/bootstrap.min.js' ], dest: 'combined.js' } }, uglify: { js: { files: { 'combined.js': ['combined.js'] } } }, }); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.registerTask('default', ['concat:js', 'uglify:js']); }; b. Explaination Gruntfile.js concat: { js: { src: [ 'lib/jquery.js', 'lib/bootstrap.min.js' ], dest: 'combined.js' } },
  • 3. Nguyễn Ngọc Dũng https://nndung179.wordpress.com Page 3 This block of codes means: you will copy all source code fron js files into 1 file call combined.js (A) Note: at src attribute, you must place js files with the order of dependency. uglify: { js: { files: { 'combined.js': ['combined.js'] } } }, This block of codes means: from combined.js (A), you will compress you js here. grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); Load all module you have installed at step 5 grunt.registerTask('default', ['concat:js', 'uglify:js']); This block of codes is very important, It means that after you do all configurations. You will register as task for Grunt to execute all tasks you have config above. 7. Result The result of this procress will be a file with jquery & bootstrap in one file under compressed format.