the future of wordpress and javascript

19
The Future of WordPress and JavaScript WordPress Cincinnati March 2016

Upload: andrew-duthie

Post on 28-Jan-2018

316 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: The Future of WordPress and JavaScript

The Future of WordPressand JavaScript

WordPress CincinnatiMarch 2016

Page 2: The Future of WordPress and JavaScript

OUTLINE• History of JavaScript

• How JavaScript is used in WordPress

• Benefits of JavaScript

• Speculating the future of WordPress

• Demo

Page 3: The Future of WordPress and JavaScript

Learn JavaScript, Deeply“ — Matt MullenwegState of the Word, WordCamp US 2015

Page 4: The Future of WordPress and JavaScript

HISTORY OF JAVASCRIPT

Page 5: The Future of WordPress and JavaScript

HISTORY OF JAVASCRIPT

• Created by Brendan Eich

• Developed over the span of ten days in May 1995

• Introduced in Netscape Navigator 2.0 (September 1995)

Page 6: The Future of WordPress and JavaScript

WHAT IS JAVASCRIPT?• One of the three essential technologies of

the web (the others being HTML and CSS)

• Supported by all major web browsers without plugins

• Standard maintained by Ecma International, currently version 6 (ECMAScript 2015)

Page 7: The Future of WordPress and JavaScript

WHAT IS JAVASCRIPT?var API_ROOT = ‘https://andrewduthie.com/wp-json';function getPosts( callback ) {

var xhr = new XMLHttpRequest();xhr.open( 'GET', API_ROOT + '/wp/v2/posts' );xhr.onreadystatechange = function() {

var posts, error;if ( 4 === xhr.readyState ) {

try {posts = JSON.parse( xhr.responseText );

} catch ( e ) {error = e;

}

callback( error, posts );}

};xhr.send();

}

Page 8: The Future of WordPress and JavaScript

WHAT IS JAVASCRIPT?

import { API_ROOT } from 'config';

export default async function getPosts() {const response = await fetch( `${ API_ROOT }/wp/v2/posts` );return await response.json();

}

Page 9: The Future of WordPress and JavaScript

JAVASCRIPT IN WORDPRESS

Page 10: The Future of WordPress and JavaScript

JAVASCRIPT IN WORDPRESS

Page 11: The Future of WordPress and JavaScript

<?php

function mytheme_scripts() {$theme_dir = get_template_directory_uri();wp_enqueue_script(

'mytheme-script', // Unique name$theme_dir . '/script.js', // Script URLarray( 'jquery' ), // Dependencies'v1.4.1', // Versiontrue // In footer

);}add_action( 'wp_enqueue_scripts', 'mytheme_scripts' );

JAVASCRIPT IN WORDPRESSIncluding your own scripts

https://codex.wordpress.org/Using_Javascript

Page 12: The Future of WordPress and JavaScript

BENEFITS OF JAVASCRIPTInteractivity

Page 13: The Future of WordPress and JavaScript

BENEFITS OF JAVASCRIPTPerceived Speed

• Display content optimistically

• Artificial content can give users the perception of speed

Page 14: The Future of WordPress and JavaScript

JAVASCRIPT’S SURGE IN POPULARITY

Better tooling for large applications

Frameworks lower barrier to entry

Same language everywhere with Node.js

Language and browser improvements

Page 15: The Future of WordPress and JavaScript

THE FUTURE OF WORDPRESS

= ???+

Page 16: The Future of WordPress and JavaScript

CALYPSO

Page 17: The Future of WordPress and JavaScript

WP-API

Page 18: The Future of WordPress and JavaScript

WP-ADMIN 2.0Note: This is not it

Page 19: The Future of WordPress and JavaScript

LIVE DEMO