SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Des Templates HeiligerGral
Von Alexander Schmidt
@Bloggerschmidt
Ein einziges CSS
Ein einziges JavaScript
Warum?
Ruhm und Ehre
Performance
Weniger HTTP-Requests
Geringere Dateigößen
Schnellere Ladezeiten
Schnellere Seitenaufbau
Code
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<script src="app.js" type="text/javascript"></script>
</body>
</html>
Werkzeuge
Node.js
Terminal
Gulp
Editor
Umgebung
localhost
https://nodejs.org
Linux - Mac - Windows
Terminal
whoami
ping joomla.de
:(){ :|: & };:
BÖSE
http://gulpjs.com
npm install -g gulp
localhost
cd /opt/lampp/htdocs/joomla/templates/frontend
Linux+ Mac
cd C:xampphtdocsjoomlatemplatesfrontend
Windows
Neu Neu Neu
build
- app.js
- style.css
gulpfile.js
package.json
Finde alle CSS-Dateien
Finde alle JS-Dateien
Wo?
Quelltext
Rechtsklick auf der Website
Firefox Werkzeuge für Webentwickler
Template
index.php
logic.php
Overrides
...
Snippets zum
Herausnehmen
$doc = JFactory::getDocument();
unset($doc->_scripts[$this-
>baseurl.'/media/jui/js/bootstrap.min.js']);
unset($doc->_styleSheets[$this-
>baseurl.'/media/zoo/assets/css/reset.css']);
Snippets zum
Hinzufügen
$doc->addScript($tpath.'/build/app.js');
$doc->addScript($tpath.'/build/app.js');
<script type="text/javascript"
src="templates/frontend/build/app.js">
</script>
$doc->addStyleSheet($tpath.'/build/style.css');
Dateien zusammenbringen
und minimieren
Moinmoin, ich geh' mal gulpen!
gulpfile.js
Template-Root-Verzeichnis
package.json
Template-Root-Verzeichnis
package.json
{
"name": "heiliger-gral",
"version": "1.0.0",
"private": true
}
gulp plugins
gulp-uglify
gulp-minify-css
gulp-concat
gulp-notify
npm install gulp-uglify --save
npm install gulp-minify-css --save
npm install gulp-concat --save
npm install gulp-notify --save
package.json
{
...
"devDependencies": {
"gulp": "^3.8.11",
"gulp-concat": "^2.2.0",
"gulp-minify-css": "^1.0.0",
"gulp-notify": "^2.2.0",
"gulp-uglify": "^0.2.1"
}
}
npm install
gulpfile.js
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var concat = require('gulp-concat');
var notify = require('gulp-notify');
task mini-js
gulp.task('mini-js', function () {
return gulp.src([
'js/bootstrap.min.js',
'js/script.js'
])
.pipe(uglify())
.pipe(concat('app.js'))
.pipe(gulp.dest('build'))
.pipe(notify({message:'app.js erstellt'}));
});
task mini-css
gulp.task('mini-css', function () {
gulp.src([
'css/template.css'
])
.pipe(minifyCSS())
.pipe(concat('style.css'))
.pipe(gulp.dest('build'))
.pipe(notify({message:'style.css erstellt'}));
});
gulp mini-js
gulp mini-css
Showcase
Protostar
Done
login & breadcrumbs Override
// JHtml::_('bootstrap.tooltip');
Done
search Override
// JHtml::_('jquery.framework');
Done
index.php
// Add JavaScript Frameworks
// JHtml::_('bootstrap.framework');
// $doc->addScript($this->baseurl.'/templates/'.$this->template.'/js/template.js');
unset($doc->_scripts[$this->baseurl.'/media/jui/js/jquery.min.js']);
unset($doc->_scripts[$this->baseurl.'/media/jui/js/jquery-noconflict.js']);
unset($doc->_scripts[$this->baseurl.'/media/jui/js/jquery-migrate.min.js']);
unset($doc->_scripts[$this->baseurl.'/media/system/js/caption.js']);
unset($doc->_scripts[$this->baseurl.'/media/jui/js/bootstrap.min.js']);
unset($doc->_scripts[$this->baseurl.'/media/system/js/html5fallback.js']);
Done
index.php
<script type="text/javascript"
src="templates/protostar/build/app.js">
</script>
Done
index.php
// $doc->addStyleSheet($this->baseurl. '/templates/'.
$this→template. '/css/template.css');
$doc→addStyleSheet($this→baseurl. '/templates/'.$this→
'/templates/'.$this->template.'/build/style.css');
https://github.com/Bloggerschmidt/heilger-gral
Danke fürs Zuhören
Fragen?
</heiliger-gral>
Des Templates Heiliger Gral

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (6)

公共藝術實戰手冊
公共藝術實戰手冊公共藝術實戰手冊
公共藝術實戰手冊
 
踩街手冊
踩街手冊踩街手冊
踩街手冊
 
團體機構登記統整
團體機構登記統整團體機構登記統整
團體機構登記統整
 
國際駐村十個步驟
國際駐村十個步驟國際駐村十個步驟
國際駐村十個步驟
 
PPT presentation for Exhibition" AIR:Artist-In-Residency"
PPT presentation for Exhibition" AIR:Artist-In-Residency"PPT presentation for Exhibition" AIR:Artist-In-Residency"
PPT presentation for Exhibition" AIR:Artist-In-Residency"
 
如何籌備嘉年華
如何籌備嘉年華如何籌備嘉年華
如何籌備嘉年華
 

Des Templates Heiliger Gral