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

ECMAScript killed the jQuery star - in TYPO3

ECMAScript killed the jQuery star - in TYPO3

A quick introduction to what JavaScript we had in TYPO3 Core, what our current state is and what we want to achieve.

Andreas Fernandez

January 17, 2020
Tweet

More Decks by Andreas Fernandez

Other Decks in Programming

Transcript

  1. [!!!][TASK] KILL PROTO- TYPES AND SCRIPT- KIDDIES WITH FIRE BENJAMIN

    MACK - HTTPS://GITHUB.COM/TYPO3/TYPO3.CMS/COMMIT/2DC43D97
  2. CURRENT STATE ▪ Modules are loaded with RequireJS ▪ Monoliths

    are split into smaller modules ▪ ExtJS is gone in v9 ▪ Introduction of ECMAscript 2015 in v10 ▪ (yes, we dropped support for IE) ▪ Code is generated by TypeScript
  3. WHERE WE‘RE HEADING TO ▪ Use native browser APIs ▪

    Enhance existing APIs ▪ Drop jQuery implementations step by step
  4. SELECTORS // jQuery const element = $('#foobar'); // native const

    element = document.querySelector('#foobar'); const element = document.getElementById('foobar');
  5. SELECTORS // jQuery const elements = $('a:not([href])'); // native const

    elements = document.querySelectorAll('a:not([href])');
  6. AJAX // jQuery $.ajax({ url: 'https://unico.rn‘, method: 'post', data: {

    type: ['pink', 'fluffy'] dancing: 'rainbows' } }).done(function (response) { console.log(response); });
  7. AJAX // native const payload = new FormData(); payload.append('type', ['pink',

    'fluffy']); fetch('https://unico.rn‘, { method: 'POST‘, body: payload }).then(async function(response) { console.log(await response.text()); });
  8. CREATE A REQUEST const request = new AjaxRequest('https://httpbin.org/json?arg1=4711'); // Add

    arguments to URL request = request.withQueryArguments({ foo: 'bar', baz: 'bencer' }); // -> https://httpbin.org/json?arg1=4711&foo=bar&baz=bencer
  9. SEND A GET REQUEST AND HANDLE RESPONSE const request =

    new AjaxRequest('https://httpbin.org/json?arg1=4711‘); request.get().then( async function (response) { console.log(await response.resolve()); console.log(response.raw()); }, function (error) { console.log(error.response); } );
  10. SEND A POST REQUEST AND HANDLE RESPONSE const request =

    new AjaxRequest('https://httpbin.org/json?arg1=4711‘); request.post({ foo: 'bar', baz: 'bencer' }).then( async function (response) { console.log(await response.resolve()); console.log(response.raw()); }, function (error) { console.log(error.response); } );