Como minimizar CSS e Javascript via linha de comando
Todo bom desenvolvedor web tem a preocupação de minimizar seus arquivos CSS e Javascript a fim de otimizar a renderização de suas páginas. Neste artigo veremos como fazer isso no GNU/Linux via linha de comando.
[ Hits: 10.504 ]
Por: Fábio Berbert de Paula em 15/04/2015 | Blog: https://fabio.automatizando.dev
#!/usr/bin/perl
my $source = shift;
if (! -f $source) {
print "Use: $0 <input-file>\n\n";
}
use JavaScript::Minifier qw(minify);
open(INFILE, $source) or die;
print minify(input => *INFILE);
close(INFILE);
/* app.js original */
/*
* Template Name: Unify - Responsive Bootstrap Template
* Description: Business, Corporate, Portfolio, E-commerce and Blog Theme.
* Version: 1.6
* Author: @htmlstream
* Website: http://htmlstream.com
*/
var App = function () {
//Bootstrap Tooltips and Popovers
function handleBootstrap() {
/*Bootstrap Carousel*/
jQuery('.carousel').carousel({
interval: 15000,
pause: 'hover'
});
/*Tooltips*/
jQuery('.tooltips').tooltip();
jQuery('.tooltips-show').tooltip('show');
jQuery('.tooltips-hide').tooltip('hide');
jQuery('.tooltips-toggle').tooltip('toggle');
jQuery('.tooltips-destroy').tooltip('destroy');
/*Popovers*/
jQuery('.popovers').popover();
jQuery('.popovers-show').popover('show');
jQuery('.popovers-hide').popover('hide');
jQuery('.popovers-toggle').popover('toggle');
jQuery('.popovers-destroy').popover('destroy');
}
//Search Box (Header)
function handleSearch() {
jQuery('.search').click(function () {
if(jQuery('.search-btn').hasClass('fa-search')){
jQuery('.search-open').fadeIn(500);
jQuery('.search-btn').removeClass('fa-search');
jQuery('.search-btn').addClass('fa-times');
} else {
jQuery('.search-open').fadeOut(500);
jQuery('.search-btn').addClass('fa-search');
jQuery('.search-btn').removeClass('fa-times');
}
});
}
//Sidebar Navigation Toggle
function handleToggle() {
jQuery('.list-toggle').on('click', function() {
jQuery(this).toggleClass('active');
});
/*
jQuery('#serviceList').on('shown.bs.collapse'), function() {
jQuery(".servicedrop").addClass('glyphicon-chevron-up').removeClass('glyphicon-chevron-down');
}
jQuery('#serviceList').on('hidden.bs.collapse'), function() {
jQuery(".servicedrop").addClass('glyphicon-chevron-down').removeClass('glyphicon-chevron-up');
}
*/
}
//Fixed Header
function handleHeader() {
jQuery(window).scroll(function() {
if (jQuery(window).scrollTop()>100){
jQuery(".header-fixed .header-sticky").addClass("header-fixed-shrink");
}
else {
jQuery(".header-fixed .header-sticky").removeClass("header-fixed-shrink");
}
});
}
//Header Mega Menu
function handleMegaMenu() {
jQuery(document).on('click', '.mega-menu .dropdown-menu', function(e) {
e.stopPropagation()
})
}
return {
init: function () {
handleBootstrap();
handleSearch();
handleToggle();
handleHeader();
handleMegaMenu();
},
//Clients Logo
initSliders: function () {
jQuery('#clients-flexslider').flexslider({
animation: "slide",
easing: "swing",
animationLoop: true,
itemWidth: 1,
itemMargin: 1,
minItems: 2,
maxItems: 9,
controlNav: false,
directionNav: false,
move: 2
});
jQuery('#clients-flexslider1').flexslider({
animation: "slide",
easing: "swing",
animationLoop: true,
itemWidth: 1,
itemMargin: 1,
minItems: 2,
maxItems: 5,
controlNav: false,
directionNav: false,
move: 2
});
jQuery('#photo-flexslider').flexslider({
animation: "slide",
controlNav: false,
animationLoop: false,
itemWidth: 80,
itemMargin: 0
});
jQuery('#testimonal_carousel').collapse({
toggle: false
});
},
//Counters
initCounter: function () {
jQuery('.counter').counterUp({
delay: 10,
time: 1000
});
},
//Parallax Backgrounds
initParallaxBg: function () {
jQuery(window).load(function() {
jQuery('.parallaxBg').parallax("50%", 0.2);
jQuery('.parallaxBg1').parallax("50%", 0.4);
});
},
};
}();
/* app-min.js */
var App=function(){function handleBootstrap(){jQuery('.carousel').carousel({interval:15000,pause:'hover'});jQuery('.tooltips').tooltip();jQuery('.tooltips-show').tooltip('show');jQuery('.tooltips-hide').tooltip('hide');jQuery('.tooltips-toggle').tooltip('toggle');jQuery('.tooltips-destroy').tooltip('destroy');jQuery('.popovers').popover();jQuery('.popovers-show').popover('show');jQuery('.popovers-hide').popover('hide');jQuery('.popovers-toggle').popover('toggle');jQuery('.popovers-destroy').popover('destroy');}
function handleSearch(){jQuery('.search').click(function(){if(jQuery('.search-btn').hasClass('fa-search')){jQuery('.search-open').fadeIn(500);jQuery('.search-btn').removeClass('fa-search');jQuery('.search-btn').addClass('fa-times');}else{jQuery('.search-open').fadeOut(500);jQuery('.search-btn').addClass('fa-search');jQuery('.search-btn').removeClass('fa-times');}});}
function handleToggle(){jQuery('.list-toggle').on('click',function(){jQuery(this).toggleClass('active');});}
function handleHeader(){jQuery(window).scroll(function(){if(jQuery(window).scrollTop()>100){jQuery(".header-fixed .header-sticky").addClass("header-fixed-shrink");}
else{jQuery(".header-fixed .header-sticky").removeClass("header-fixed-shrink");}});}
function handleMegaMenu(){jQuery(document).on('click','.mega-menu .dropdown-menu',function(e){e.stopPropagation()})}
return{init:function(){handleBootstrap();handleSearch();handleToggle();handleHeader();handleMegaMenu();},initSliders:function(){jQuery('#clients-flexslider').flexslider({animation:"slide",easing:"swing",animationLoop:true,itemWidth:1,itemMargin:1,minItems:2,maxItems:9,controlNav:false,directionNav:false,move:2});jQuery('#clients-flexslider1').flexslider({animation:"slide",easing:"swing",animationLoop:true,itemWidth:1,itemMargin:1,minItems:2,maxItems:5,controlNav:false,directionNav:false,move:2});jQuery('#photo-flexslider').flexslider({animation:"slide",controlNav:false,animationLoop:false,itemWidth:80,itemMargin:0});jQuery('#testimonal_carousel').collapse({toggle:false});},initCounter:function(){jQuery('.counter').counterUp({delay:10,time:1000});},initParallaxBg:function(){jQuery(window).load(function(){jQuery('.parallaxBg').parallax("50%",0.2);jQuery('.parallaxBg1').parallax("50%",0.4);});},};}();
Fazendo seu Linux falar com espeak
cpulimit - Limitando o uso da CPU por processo
Firefox 2 e seu recurso de proteção contra Web Phishing
Docalysis: Análise de Documentos com Inteligência Artificial
Criando sites para celular com WML
MathML - Mathematical Markup Language
Como camuflar seu WhatsApp Web usando Snippets JavaScript
Jakarta JMeter - Testando o desempenho de seus sites
Diferenças de sites Web Standards
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Linux em 2025: Segurança prática para o usuário
Desktop Linux em alta: novos apps, distros e privacidade marcam o sábado
IA chega ao desktop e impulsiona produtividade no mundo Linux
Novos apps de produtividade, avanços em IA e distros em ebulição agitam o universo Linux
Como instalar o repositório do DBeaver no Ubuntu
Como instalar o Plex Media Server no Ubuntu
Digitando underscore com "shift" + "barra de espaços"
Como ativar a lixeira e recuperar aquivos deletados em um servidor Linux
Como mudar o nome de dispositivos Bluetooth via linha de comando
Programa fora de escala na tela do pc (10)
Fedora KDE plasma 42 X Módulo de segurança BB (Warsaw-2) (1)
O programa assinador digital (1)









