SlideShare a Scribd company logo
Once upon a time…
there were css, js
and server-side rendering
A long time ago...
in a galaxy far far away
A long time ago...
in a galaxy far far away
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
PHP template engines
● Smarty (2002)
● Twig (Symfony)
● Mustache (Logic-less templates)
● Blade (Laravel 4)
● Volt (Phalcon)
// guestbook.tpl
Style inline is a smell
but...
File too big
Organize styles logically
Once upon a time, there were css, js and server-side rendering
// index.html
// main.css
Once upon a time, there were css, js and server-side rendering
Designers’ hell at 2000s
● CSS
○ Cascading Style Sheet
○ Browser compatibility
○ Huge single file or external HTTP imports
○ Selector Priority (a#a-02 is more specific than a[id=”a-02”]?)
○ Cascading.
Designers’ hell at 2000s
Designers’ hell at 2000s
Assets file tree
assets/
├── css
│ ├── bootstrap.min.css
│ ├── magnific-popup.min.css
│ ├── videojs.min.css
│ └── main.css
├── fonts/
└── images/
The birth of preprocessors
LESS and SASS were born to solve the bad things of CSS inspired by software
development.
● local imports
● variables
● functions
● reusable code
More tools!
$ lessc main.less main.css
$ sass input.scss output.css
Assets file tree with less
assets/
├── less
│ ├── global.less
│ ├── main.less
│ ├── utils
│ │ ├── animations.less
│ │ ├── device-label.less
│ │ ├── generators.less
│ │ ├── helpers.less
│ │ ├── media-queries.less
│ │ ├── positions.less
│ │ ├── shadows.less
│ │ └── sizes.less
│ └── webfonts.less
├── css
│ ├── bootstrap.min.css
│ ├── magnific-popup.min.css
│ ├── videojs.min.css
│ └── main.min.css
├── fonts/
└── images/
Why reinvent the wheel?
● jQuery
● Bootstrap
● Foundation
● Magnific Popup
● JWPlayer
● jQuery Mobile
● Video.js
● Sencha Touch
● Backbone
● jQuery UI
● D3.js
● Chosen
● Handlebars
● Underscore
● JQuery-File-Upload
● Prototype
● Dojo
● jquery-select
● jquery-gallery
● jquery-pokemon-go
Meanwhile the assets directory ...
Bower
● Package Manager by Twitter
● Bower.json: single configuration file with all frontend dependencies
● Automatic download
● Flat dependencies tree
● Dependency upgrade with one command
MORE TOOLS
● bower init
● bower install <package> --save
● bower install
$ bower install jquery
Assets file tree with bower
assets/
├── bower_components
│ ├── bootstrap/
│ ├── magnific-popup/
│ └── videojs/
├── less
│ ├── global.less
│ ├── main.less
│ ├── utils/
│ └── webfonts.less
├── css
│ └── main.min.css
├── fonts/
└── images/
Wait… There were also some small jquery
javascript script for carousels and popups.
And then?
And then …
BOOM!
NodeJS
CommonJS
● NodeJS love
● Explosion of packages and tools written for node.js
● Modularization as hell (require(‘left-pad’))
● Encapsulated code with specific exports (module.exports = PokemonGo)
● No more self-invoking functions!
● Small files
Front-end developers’ problem
● Code complexity grows as the site gets bigger
● Assembly gets harder
● Developer wants discrete JS files/modules
● Deployment wants optimized code in just one or a few HTTP calls
NodeJS is so cool! Why I can’t use it on my
frontend development?
I need a magic!
Browserify
● Small wrapper for the require function
● Build process that keeps track of dependencies
● Bundle to one file
More tools
browserify index.js > bundle.js
Assets file tree with browserify
assets/
├── bower_components/
├── node_modules/
├── less/
├── dist
│ ├── bundle.js
│ └── main.min.css
├── js
│ ├── Components
│ │ ├── Modals.js
│ │ └── Slideshow.js
│ ├── Models
│ │ ├── User.js
│ │ └── Product.js
│ └── main.js
├── fonts/
└── images/
Once upon a time, there were css, js and server-side rendering
*choose-a-language* to JavaScript
● Coffeescript to JavaScript - coffeescript.org
● TypeScript to JavaScript - typescriptlang.org
● Dart to JavaScript - dartlang.org
● C/C++ to JavaScript - Emscripten
● ES6 to ES5 - babel
● JavaScript to JavaScript - js2js
A new frontend environement
● Single page application
● Web App
● Front-end frameworks:
○ Backbone + jQuery
○ Angular
○ Ember
○ Meteor
○ React.js
● The V of MVC is moved to browsers
● Front-end designers became Front-end developers
● Backend developers and Front-end developers meet together only in one way...
API REST
Recap tools
● less / sass
● browserify / webpack / rollup
● uglify
● transpilers
● imagemin
● watch
● livereload
● ...
I need a task runner
But before I need to node and npm
// package.json - created with '$ npm init'
{
"name": "my-awesome-project",
"version": "0.1.0",
"description": "My Awesome Project",
"scripts": {
"build": "node_modules/grunt-cli/bin/grunt dist",
"start": "node_modules/grunt-cli/bin/grunt dev"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-cli": "~1.2.0",
"grunt-contrib-sass": "~1.0.0"
}
"author": "RomaJS"
}
Grunt
module.exports = function(grunt) {
grunt.initConfig({
sass: {
dist: {
files: {
'style/style.css': 'sass/style.scss'
}
}
},
watch: {
css: {
files: '**/*.scss',
tasks: ['sass']
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('start',['sass', 'watch']);
grunt.registerTask('build',['sass']);
}
● grunt-contrib-cssmin
● grunt-contrib-less
● grunt-contrib-concat
● grunt-contrib-uglify
● grunt-contrib-imagemin
● grunt-contrib-copy
● grunt-contrib-clean
● grunt-contrib-livereload
● grunt-contrib-jshint
● grunt-eslint
● grunt-pokemon-go
● ...
// gruntfile.js
Gulp
var gulp = require('gulp'),
sass = require('gulp-sass');
gulp.task('scripts', function() {
return gulp.src(['bower_components/jquery/jquery-1.11.1.js', 'src/**/*.js'])
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/build'));
});
gulp.task('styles', function() {
gulp.src('sass/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./css/'))
});
//Watch task
gulp.task('default', ['scripts', 'styles'], function() {
gulp.watch('sass/**/*.scss',['styles']);
gulp.watch(['js/**/*.js'], ['scripts'])
});
● gulp-cssmin
● gulp-less
● gulp-concat
● gulp-uglify
● gulp-imagemin
● gulp-copy
● gulp-clean
● gulp-livereload
● gulp-jshint
● gulp-eslint
// gulpfile.js
Webpack
module.exports = {
entry: './src/js/main.js',
module: {
loaders: [{
test: /.js$/,
loader: 'babel',
query: {
presets: ['es2015', 'react', 'stage-0']
}
},
{
test: /.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css!less')
}]
},
output: {
filename: 'bundle.js',
path: __dirname + '/../web/assets'
}
};
● creates one or many
bundles
● allow commonjs and es6
● webpack-dev-server
○ watch
○ livereload
● loaders +150
○ sass
○ less
● plugins +30
○ uglifyJs
○ imagemin
○ commonsChunk
// webpack.config.js
Demo Time?
@JellyBellyDev @MatteoManchi
Thank You!
Ad

More Related Content

What's hot (20)

Webpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSWebpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JS
Emil Öberg
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack Introduction
Anjali Chawla
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to now
Derek Willian Stavis
 
Browserify
BrowserifyBrowserify
Browserify
davidchubbs
 
Webpack
WebpackWebpack
Webpack
Anjali Chawla
 
Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
Spike Brehm
 
Lightning Talk: Making JS better with Browserify
Lightning Talk: Making JS better with BrowserifyLightning Talk: Making JS better with Browserify
Lightning Talk: Making JS better with Browserify
crgwbr
 
JavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & BrowserifyJavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & Browserify
Johan Nilsson
 
Bower power
Bower powerBower power
Bower power
Eric Carlisle
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflow
Riccardo Coppola
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash Course
Aaron Silverman
 
Angular2 ecosystem
Angular2 ecosystemAngular2 ecosystem
Angular2 ecosystem
Kamil Lelonek
 
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Ryan Weaver
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
Beau Lebens
 
JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic Apps
Spike Brehm
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)
Spike Brehm
 
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development Environments
Beau Lebens
 
Bower - A package manager for the web
Bower - A package manager for the webBower - A package manager for the web
Bower - A package manager for the web
Larry Nung
 
Put a little Backbone in your WordPress
Put a little Backbone in your WordPressPut a little Backbone in your WordPress
Put a little Backbone in your WordPress
adamsilverstein
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
Chandrasekar G
 
Webpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSWebpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JS
Emil Öberg
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack Introduction
Anjali Chawla
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to now
Derek Willian Stavis
 
Integrating Browserify with Sprockets
Integrating Browserify with SprocketsIntegrating Browserify with Sprockets
Integrating Browserify with Sprockets
Spike Brehm
 
Lightning Talk: Making JS better with Browserify
Lightning Talk: Making JS better with BrowserifyLightning Talk: Making JS better with Browserify
Lightning Talk: Making JS better with Browserify
crgwbr
 
JavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & BrowserifyJavaScript Dependencies, Modules & Browserify
JavaScript Dependencies, Modules & Browserify
Johan Nilsson
 
Bower & Grunt - A practical workflow
Bower & Grunt - A practical workflowBower & Grunt - A practical workflow
Bower & Grunt - A practical workflow
Riccardo Coppola
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash Course
Aaron Silverman
 
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other ToolsCool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
Ryan Weaver
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
Beau Lebens
 
JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic Apps
Spike Brehm
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)
Spike Brehm
 
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development Environments
Beau Lebens
 
Bower - A package manager for the web
Bower - A package manager for the webBower - A package manager for the web
Bower - A package manager for the web
Larry Nung
 
Put a little Backbone in your WordPress
Put a little Backbone in your WordPressPut a little Backbone in your WordPress
Put a little Backbone in your WordPress
adamsilverstein
 

Similar to Once upon a time, there were css, js and server-side rendering (20)

I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
Michael Lange
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
Women in Technology Poland
 
Docker 101
Docker 101 Docker 101
Docker 101
Kevin Nord
 
Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
Manuel Eusebio de Paz Carmona
 
Architektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausArchitektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan Kraus
Women in Technology Poland
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Develcz
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
async_io
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An Introduction
Nirvanic Labs
 
A Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and ContainersA Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and Containers
Docker, Inc.
 
Nodejs web service for starters
Nodejs web service for startersNodejs web service for starters
Nodejs web service for starters
Bruce Li
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
Horacio Gonzalez
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
corehard_by
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
drupalcampest
 
Super powered Drupal development with docker
Super powered Drupal development with dockerSuper powered Drupal development with docker
Super powered Drupal development with docker
Maciej Lukianski
 
New paradigms
New paradigmsNew paradigms
New paradigms
Borja A. Espejo García
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
Robert Lujo
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
Samuel Chow
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and Containers
Docker, Inc.
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkit
Paul Jensen
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
Michael Lange
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
Women in Technology Poland
 
Architektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausArchitektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan Kraus
Women in Technology Poland
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Develcz
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
async_io
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An Introduction
Nirvanic Labs
 
A Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and ContainersA Gentle Introduction to Docker and Containers
A Gentle Introduction to Docker and Containers
Docker, Inc.
 
Nodejs web service for starters
Nodejs web service for startersNodejs web service for starters
Nodejs web service for starters
Bruce Li
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
Horacio Gonzalez
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
corehard_by
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
drupalcampest
 
Super powered Drupal development with docker
Super powered Drupal development with dockerSuper powered Drupal development with docker
Super powered Drupal development with docker
Maciej Lukianski
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
Robert Lujo
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
Samuel Chow
 
Introduction to Docker and Containers
Introduction to Docker and ContainersIntroduction to Docker and Containers
Introduction to Docker and Containers
Docker, Inc.
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkit
Paul Jensen
 
Ad

Recently uploaded (20)

Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Ad

Once upon a time, there were css, js and server-side rendering

  • 1. Once upon a time… there were css, js and server-side rendering
  • 2. A long time ago... in a galaxy far far away A long time ago... in a galaxy far far away
  • 6. PHP template engines ● Smarty (2002) ● Twig (Symfony) ● Mustache (Logic-less templates) ● Blade (Laravel 4) ● Volt (Phalcon)
  • 8. Style inline is a smell but...
  • 14. Designers’ hell at 2000s ● CSS ○ Cascading Style Sheet ○ Browser compatibility ○ Huge single file or external HTTP imports ○ Selector Priority (a#a-02 is more specific than a[id=”a-02”]?) ○ Cascading.
  • 17. Assets file tree assets/ ├── css │ ├── bootstrap.min.css │ ├── magnific-popup.min.css │ ├── videojs.min.css │ └── main.css ├── fonts/ └── images/
  • 18. The birth of preprocessors LESS and SASS were born to solve the bad things of CSS inspired by software development. ● local imports ● variables ● functions ● reusable code
  • 19. More tools! $ lessc main.less main.css $ sass input.scss output.css
  • 20. Assets file tree with less assets/ ├── less │ ├── global.less │ ├── main.less │ ├── utils │ │ ├── animations.less │ │ ├── device-label.less │ │ ├── generators.less │ │ ├── helpers.less │ │ ├── media-queries.less │ │ ├── positions.less │ │ ├── shadows.less │ │ └── sizes.less │ └── webfonts.less ├── css │ ├── bootstrap.min.css │ ├── magnific-popup.min.css │ ├── videojs.min.css │ └── main.min.css ├── fonts/ └── images/
  • 21. Why reinvent the wheel? ● jQuery ● Bootstrap ● Foundation ● Magnific Popup ● JWPlayer ● jQuery Mobile ● Video.js ● Sencha Touch ● Backbone ● jQuery UI ● D3.js ● Chosen ● Handlebars ● Underscore ● JQuery-File-Upload ● Prototype ● Dojo ● jquery-select ● jquery-gallery ● jquery-pokemon-go
  • 22. Meanwhile the assets directory ...
  • 23. Bower ● Package Manager by Twitter ● Bower.json: single configuration file with all frontend dependencies ● Automatic download ● Flat dependencies tree ● Dependency upgrade with one command MORE TOOLS ● bower init ● bower install <package> --save ● bower install
  • 24. $ bower install jquery
  • 25. Assets file tree with bower assets/ ├── bower_components │ ├── bootstrap/ │ ├── magnific-popup/ │ └── videojs/ ├── less │ ├── global.less │ ├── main.less │ ├── utils/ │ └── webfonts.less ├── css │ └── main.min.css ├── fonts/ └── images/
  • 26. Wait… There were also some small jquery javascript script for carousels and popups. And then?
  • 28. CommonJS ● NodeJS love ● Explosion of packages and tools written for node.js ● Modularization as hell (require(‘left-pad’)) ● Encapsulated code with specific exports (module.exports = PokemonGo) ● No more self-invoking functions! ● Small files
  • 29. Front-end developers’ problem ● Code complexity grows as the site gets bigger ● Assembly gets harder ● Developer wants discrete JS files/modules ● Deployment wants optimized code in just one or a few HTTP calls
  • 30. NodeJS is so cool! Why I can’t use it on my frontend development? I need a magic!
  • 31. Browserify ● Small wrapper for the require function ● Build process that keeps track of dependencies ● Bundle to one file More tools browserify index.js > bundle.js
  • 32. Assets file tree with browserify assets/ ├── bower_components/ ├── node_modules/ ├── less/ ├── dist │ ├── bundle.js │ └── main.min.css ├── js │ ├── Components │ │ ├── Modals.js │ │ └── Slideshow.js │ ├── Models │ │ ├── User.js │ │ └── Product.js │ └── main.js ├── fonts/ └── images/
  • 34. *choose-a-language* to JavaScript ● Coffeescript to JavaScript - coffeescript.org ● TypeScript to JavaScript - typescriptlang.org ● Dart to JavaScript - dartlang.org ● C/C++ to JavaScript - Emscripten ● ES6 to ES5 - babel ● JavaScript to JavaScript - js2js
  • 35. A new frontend environement ● Single page application ● Web App ● Front-end frameworks: ○ Backbone + jQuery ○ Angular ○ Ember ○ Meteor ○ React.js ● The V of MVC is moved to browsers ● Front-end designers became Front-end developers ● Backend developers and Front-end developers meet together only in one way...
  • 37. Recap tools ● less / sass ● browserify / webpack / rollup ● uglify ● transpilers ● imagemin ● watch ● livereload ● ...
  • 38. I need a task runner
  • 39. But before I need to node and npm // package.json - created with '$ npm init' { "name": "my-awesome-project", "version": "0.1.0", "description": "My Awesome Project", "scripts": { "build": "node_modules/grunt-cli/bin/grunt dist", "start": "node_modules/grunt-cli/bin/grunt dev" }, "devDependencies": { "grunt": "~0.4.5", "grunt-cli": "~1.2.0", "grunt-contrib-sass": "~1.0.0" } "author": "RomaJS" }
  • 40. Grunt module.exports = function(grunt) { grunt.initConfig({ sass: { dist: { files: { 'style/style.css': 'sass/style.scss' } } }, watch: { css: { files: '**/*.scss', tasks: ['sass'] } } }); grunt.loadNpmTasks('grunt-contrib-sass'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('start',['sass', 'watch']); grunt.registerTask('build',['sass']); } ● grunt-contrib-cssmin ● grunt-contrib-less ● grunt-contrib-concat ● grunt-contrib-uglify ● grunt-contrib-imagemin ● grunt-contrib-copy ● grunt-contrib-clean ● grunt-contrib-livereload ● grunt-contrib-jshint ● grunt-eslint ● grunt-pokemon-go ● ... // gruntfile.js
  • 41. Gulp var gulp = require('gulp'), sass = require('gulp-sass'); gulp.task('scripts', function() { return gulp.src(['bower_components/jquery/jquery-1.11.1.js', 'src/**/*.js']) .pipe(concat('main.js')) .pipe(uglify()) .pipe(gulp.dest('dist/build')); }); gulp.task('styles', function() { gulp.src('sass/**/*.scss') .pipe(sass().on('error', sass.logError)) .pipe(gulp.dest('./css/')) }); //Watch task gulp.task('default', ['scripts', 'styles'], function() { gulp.watch('sass/**/*.scss',['styles']); gulp.watch(['js/**/*.js'], ['scripts']) }); ● gulp-cssmin ● gulp-less ● gulp-concat ● gulp-uglify ● gulp-imagemin ● gulp-copy ● gulp-clean ● gulp-livereload ● gulp-jshint ● gulp-eslint // gulpfile.js
  • 42. Webpack module.exports = { entry: './src/js/main.js', module: { loaders: [{ test: /.js$/, loader: 'babel', query: { presets: ['es2015', 'react', 'stage-0'] } }, { test: /.less$/, loader: ExtractTextPlugin.extract('style-loader', 'css!less') }] }, output: { filename: 'bundle.js', path: __dirname + '/../web/assets' } }; ● creates one or many bundles ● allow commonjs and es6 ● webpack-dev-server ○ watch ○ livereload ● loaders +150 ○ sass ○ less ● plugins +30 ○ uglifyJs ○ imagemin ○ commonsChunk // webpack.config.js
  翻译: