Jan Weinschenker und Oliver Ochs (Holisticon AG)
In diesem Vortrag geht es um eine konkrete Website. Im ersten Teil des Vortrags stellen wir die wichtigsten Optimierungsmaßnahmen vor, die außerhalb eines Builds durchgeführt wurden. Für eine dauerhafte, nachhaltige Performance-Optimierung müssen die Maßnahmen automatisiert bzw. in den Build-Prozess integriert werden. Im zweiten Teil des Vortrags zeigen wir einen beispielhaften Build-Prozess für Java-Webanwendungen, der Teile der Optimierungsmaßnahmen durchführt. Andere Teile müssen durch eine geeignete Architektur sichergestellt werden, wofür wir ebenfalls Ideen liefern.
10. URI-Builder
Gleichmäßige Verteilung zwischen statischen Hosts
URLs beinhalten Versionsnummer / Publikationsdatum als URL-Segment
-> neuer Content im Repository bekommt neue URL
CSS, PNG, JS, PDF
Content Repository Webapplikation
9
11. Templating
CSS in den Seitenkopf einbauen
CSS vor JavaScript einbinden
Globales JavaScript im Header einbinden (Head.js möglich)
Lokale JavaScript inlinen bzw. im Fuß der Seite einbinden
Lade 3rd Party-Content asynchron nach document.ready
-> Reduziere / verschiebe DNS-Lookups
HTML-Minification / Inline-JS-Minification
Hintergrundbild
Cory Doctorow
10
12. Einmal optimiert – und immer wieder gebrochen
JavaScript kombinieren und minifizieren
CSS kombinieren und minifizieren
Image-Spriting
JPEG / PNG optimieren
Testing-Code entfernen (e.g. ;;; console.log(this);)
Hintergrundbild
„Sisyphus“, Franz von Stuck, 1920
11
13. „Für eine dauerhafte, nachhaltige
Performance-Optimierung
müssen die Maßnahmen
automatisiert bzw. in
den Build-Prozess integriert
werden.“
Markus Leptien
Telefónica Germany
VP Online & VAS Development
15. Build-System für Frontend-Projekt
Analog zu Java-Build:
Ressourcen im SVN eingecheckt
Maven erzeugt ein versioniertes,
deploybares Artefakt (WAR-Datei)
Assets werden in das CMS importiert und
durch das CMS ausgeliefert
Es werden sowohl die Quell- als auch die
Ziel-Assets in das CMS importiert.
Optimierungen lassen sich zum Testen
ausschalten.
Bild:
MakerBot Industries
19. Web Resource Optimizer
for Java
Free and Open Source Java project which brings
together almost all the modern web tools: JsHint,
CssLint, JsMin, Google Closure compressor, YUI
Compressor, UglifyJs, Dojo Shrinksafe, Css
Variables Support, JSON Compression, Less, Sass,
CoffeeScript and much more.
-- http:/code.google.com/p/wro4j/
19
29. Code Quality
CSSLint- CSS Lint is a tool to help point out problems
with your CSS code. It does basic syntax checking as
well as applying a set of rules to the code that look
for problematic patterns or signs of inefficiency. The
rules are all pluggable, so you can easily write your
own or omit ones you don't want.
-- http:/css/lint.net
29
30. CSS-Lint-Meldungen
Parsing Errors Expected RBRACE at line All
384, col 3. */
body#provider div.container_tsr_content div.unavailable_icon .unavailableType
{
top: 76px;
right: 12px;
*/
}
30
33. OptiPNG
OptiPNG is a PNG optimizer that recompresses image files to
a smaller size, without losing any information. This program
also converts external formats (BMP, GIF, PNM and TIFF) to
optimized PNG, and performs PNG integrity checks and
corrections.
-- http:/optipng.sourceforge.net/
-- https:/github.com/hammerhead/maven-optipng-plugin
34
43. Linting
JSLint - ... Will hurt your feelings. It takes a JavaScript
source and scans it. If it finds a problem, it returns a
message describing the problem and an approximate
location within the source. The problem is not
necessarily a syntax error, although it often is.
-- http:/www.jslint.com/lint.html
-- http:/code.google.com/p/jslint4java/
49
48. Executing Jasmine Specs
-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
J
A
S
M
I
N
E
S
P
E
C
S
-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐
[INFO]
Jasmine
makes
testing
JavaScript
awesome
StringUtils.trim
should
trim
a
string
StringUtils.beginsWith
and
StringUtils.endsWith
should
match
a
specified
string
on
the
beginning
of
a
string
should
match
a
specified
string
on
the
ending
of
a
string
Mapping
CID
incl
PostViewSales
should
map
Alice
S
+
Option
Home&Go
Surf-‐flat
L
1
Monat
(dslSIE
ohne
MVLZ
with
option
mobileDataL)
to
246201
should
map
Alice
M
+
Option
Home&Go
Surf-‐flat
L
1
Monat
(dslMIE
ohne
MVLZ
with
option
mobileDataL)
to
246209
should
map
Alice
L
+
Option
Home&Go
Surf-‐flat
L
1
Monat
(dslLIE
ohne
MVLZ
with
option
mobileDataL)
to
246217
should
map
Alice
S
+
Option
Home&Go
Surf-‐flat
L
24
Monate
(dslSIE
with
MVLZ
with
option
mobileDataL)
to
246203
should
map
Alice
M
+
Option
Home&Go
Surf-‐flat
L
24
Monate
(dslMIE
with
MVLZ
with
option
mobileDataL)
to
246211
should
map
Alice
L
+
Option
Home&Go
Surf-‐flat
L
24
Monate
(dslLIE
with
MVLZ
with
option
mobileDataL)
to
246219
[…]
Results:
138
specs,
0
failures
55
50. Documentation
JSDocToolkit - JsDoc Toolkit is an application, written
in JavaScript, for automatically generating template-
formatted, multi-page HTML (or XML, JSON, or any
other text-based) documentation from commented
JavaScript source code.
-- http:/code.google.com/p/jsdoc-toolkit/
-- http:/code.google.com/p/jsdoctk-plugin/
57
56. This file is licensed under the Creative Commons Attribution-Share Alike 2.0 Generic license. You are free:to share – to copy, distribute and transmit the work to remix – to adapt the work Under the following conditions:
attribution – You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
share alike – If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
Alle Markennamen, Firmennamen oder Logos sind Warenzeichen der jeweiligen Unternehmen bzw. Rechte-Inhaber.
Die Bilder der Server stammen von Sun Microsystems bzw. ORACLE CORPORATION. Das Bild vom MakerBot stammt von MakerBot Industries. Das Bild des Entwickler-Rechners stammt von HP.