Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Benefits of Vanilla JavaScript (for the jQu...

Nate Conley
September 12, 2017

The Benefits of Vanilla JavaScript (for the jQuery Developer)

Nate Conley

September 12, 2017
Tweet

More Decks by Nate Conley

Other Decks in Technology

Transcript

  1. DOM

  2. Selecting DOM Elements document.getElementById() document.querySelector() document.querySelectorAll() - Get one element

    by ID selector - Get one element by CSS-like selector - Get all elements by CSS-like selector
  3. More DOM Topics Traversing the DOM Form Manipulation Styles element.parentNode.firstChild

    getSiblings( element ) element.value element.style.backgroundColor = ‘red’
  4. var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if

    ( xhr.readyState == 4 && xhr.status == 200 ) { // Do something } } xhr.open( ‘GET’, ‘/wp-json/wp/v2/posts’, true ); xhr.send();
  5. Fetch API Supported in major browsers, but no IE11 davidwalsh.name/fetch

    fetch( '/wp-json/wp/v2/posts', { method: ‘GET' } ) .then( function( response ) { // Do something } ) .catch( function( error ) { // Do something } );
  6. Learn More • JavaScript 30 - wesbos.com/javascript30 • Plain JS

    - plainjs.com • JavaScript for WordPress - javascriptforwp.com • You Might Not Need jQuery - youmightnotneedjquery.com
  7. Learn More • From jQuery to JavaScript - code.tutsplus.com/ tutorials/from-jquery-to-javascript-a-reference--

    net-23703 • Sans jQuery - gist.github.com/joyrexus/7307312 • Wes Bos Resources - wesbos.com/learn-javascript/ • Parallax Done Right - medium.com/@dhg/parallax- done-right-82ced812e61c