Slide 1

Slide 1 text

Return of the
 tag Paul Heasley
 @pheasley

Slide 2

Slide 2 text

bundling is wasting bandwidth native ES6 modules dependencies via unpkg ∠

Slide 3

Slide 3 text

the evolution of script tags

Slide 4

Slide 4 text

the evolution of script tags

Slide 5

Slide 5 text

the evolution of script tags

Slide 6

Slide 6 text

the evolution of script tags issues included: • ordering of script tags • polluting global namespace • concurrent connections limit

Slide 7

Slide 7 text

the evolution of script tags

Slide 8

Slide 8 text

browserify / webpack // webpack.config.js module.exports = { entry: './src/app.js' }; // src/app.js const Foo = require('./foo.js');

Slide 9

Slide 9 text

webpack makes it too easy to bundle all your dependencies

Slide 10

Slide 10 text

how much of your app is your code?

Slide 11

Slide 11 text

on average* 4.5%

Slide 12

Slide 12 text

continuous delivery invalidates the browser cache multiple times per day

Slide 13

Slide 13 text

server side bundling negates the benefits of browser caching

Slide 14

Slide 14 text

the solution? use more script tags download only what changed

Slide 15

Slide 15 text

use CDNs for dependencies (they’ll be cached across sites)

Slide 16

Slide 16 text

bundling is wasting bandwidth native ES6 modules dependencies via unpkg ∠

Slide 17

Slide 17 text

ES6 module format // CommonJS style module.exports = Foo; const Foo = require('./foo.js'); // ES6 modules export default Foo; import Foo from './foo.js';

Slide 18

Slide 18 text

ES6 module format // Inline named exports export const FOO = “foo"; // All at once named exports export { FOO, bar }; // Default export (one per file) export default class Bar {}

Slide 19

Slide 19 text

ES6 module format // Named imports import { FOO, bar } from ‘./utils.js’; // Rename imports import { FOO, bar as alias } from ‘./utils.js'; // Import everthing to a single object import * as utils from ‘./utils.js'; // Import default import Bar from './utils.js';

Slide 20

Slide 20 text

native ES6 modules browser support is here

Slide 21

Slide 21 text

use script type=module import { render } from './utils.js'; render('Hello World');

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

supported in: IE Edge (v17 Apr 30, 2018) Firefox (v60 May 9, 2018) Chrome (v64 Jan 24, 2018) Safari (v11 Sep 19, 2017) iOS Safari (v11.2 Sep 19, 2017) Chrome for Android (v66 Apr 17, 2018) " " " " " " #

Slide 24

Slide 24 text

use “nomodule” for backwards compatibility

Slide 25

Slide 25 text

bundling is wasting bandwidth native ES6 modules dependencies via unpkg ∠

Slide 26

Slide 26 text

unpkg the CDN for everything on NPM

Slide 27

Slide 27 text

the many faces of unpkg https://unpkg.com/rxjs —> entry point of the latest version https://unpkg.com/rxjs@5 —> entry point of a specific version https://unpkg.com/rxjs/package.json —> a specific file https://unpkg.com/rxjs/ —> directory listing https://unpkg.com/rxjs?module —> es6 modules entry point

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

load dependencies as modules import Vue from ‘https://unpkg.com/vue?module'; import { fromEvent } from ‘https://unpkg.com/rxjs?module';

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

HTTP/2 performance improvements: • binary framing layer • connection multiplexing

Slide 32

Slide 32 text

HTTP/2 “bundling on the fly”

Slide 33

Slide 33 text

the future is… optimised browser caching es6 modules dependencies via CDNs

Slide 34

Slide 34 text

Thanks. Paul Heasley
 @pheasley