45
Booting up with Polymer @marcushellberg / vaadin

Booting up with polymer

Embed Size (px)

Citation preview

Booting up with Polymer

@marcushellberg / vaadin

Why Web Components?

4 standards

– Custom elements

– HTML Imports

– Templates

– Shadow DOM

Do browsers support this?

Source: webcomponents.org

webcomponents.js

now also available as lite!

What is Polymer then?

– Helper library for building Web Components

– Comes with a collection of ready made Web Components

Building apps with Polymer

do we need a framework?

... the DOM is the framework

– Component model (= HTML elements)

– Data flow (= attributes, properties and events)

– Declarative format (= HTML)

– Extensible through Web Components

Building apps out of components

– Composition

– Encapsulation

– Mediator pattern

Business logic

API API

APIcomponent

child 1 child 2

full stack app

backend

Spring Boot

Takes an opinionated view of building production-ready Spring applications. Spring Boot favors convention over configuration and is designed to get you up and running as quickly as possible.

– Create stand-alone Spring applications

– Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)

– Provide opinionated 'starter' POMs to simplify your Maven configuration

– Automatically configure Spring whenever possible

– Production-ready features such as metrics, health checks and externalized configuration

– Absolutely no code generation and no requirement for XML configuration

projects.spring.io/spring-boot

start.spring.io

Token authentication

– JSON Web Token

– Compact

– Self-contained

– header.payload.signature

JWT authentication

Client Server

1. Login request (username/password)

2. token gets returned to browser Authenticate, create token

3. Request, token in header

4. Response Validate token

Polymer app

Some additional tools we'll use

npm – development time JS dependencies

bower – Polymer dependencies

gulp – JS based build tool used to run some optimization tasks

...integrated into Maven build process

server

<summary-panel>

<login-page>

<expenses-editor>

<expense-application>

<expenses-page>

<expenses-list>

performance?

Optimizing

vulcanize – combine all imports into one file

crisper – pull out all JS into separate file for CSP compliance

htmlmin & uglify – minimize assets

turn on server gzip

gulp.task('build', function() { return gulp .src(SRC_DIR + '/elements.html') .pipe($.vulcanize({ inlineScripts: true, inlineCss: true })) .pipe($.crisper()) .pipe($.if('*.js', $.uglify({ preserveComments: 'some' }))) .pipe($.if('*.html', $.htmlmin({ customAttrAssign: [/\$=/], removeComments: true, collapseWhitespace: true }))) .pipe(gulp.dest(DEST_DIR)); });

mvncleanpackage-Pproduction

..more!

Load imports asynchronously

Style "app skeleton"

Use native shadow DOM where available

80% smaller and faster start

production?

Getting started with

github.com/vaadin-marcus/polymer-spring-boot

?!

thanks!

[email protected] @marcushellberg