165 reactions · 27 shares | Despite having access to advanced JavaScript frameworks, many web developers continue to write very similar boilerplate code to setup AJAX interactions. Facebook, in particular, peaked at nearly one megabyte of JavaScript on its homepage. The team then realized that 90% of our interactions could be boiled down into a very small set of steps: (1) User clicks on a link or submits a form, (2) an AJAX request is sent to the server..., (3) some markup is put into the DOM.
By framing nearly all interactions in this manner, we have been able to put a small snippet of JavaScript, Primer, at the top of all pages that can listen to and wire up these interactions. Built atop plain links and forms, we have created a simple, fast, accessible way to implement most interactions on our site.
In conjunction with a few other systems, Haste for packaging and dependency management, and Bootloader for on-demand loading of static resources, Primer has changed the way we write JavaScript for the better. | Engineering at Meta
Despite having access to advanced JavaScript frameworks, many web developers continue to write very similar boilerplate code to setup AJAX interactions. Facebook, in particular, peaked at nearly one...
facebook.com