Skip to main content Accessibility Feedback

Vanilla JavaScript and Performance

Addy Osmani from Google shared this incredible graph on JavaScript performance on Twitter this weekend:

This graph shows average JavaScript parse times for various devices. For newer devices (like the iPhone 7), parse times are almost on par with desktop devices. For older devices (which many, many people still use) parse times can be 3-4x slower than desktop.

Addy explains:

That said, even a small bundle, written poorly or with poor library choices can result in the main thread being pegged for a long time in compilation or function call times. It’s important to holistically measure and understand where our real bottlenecks are.

Just using vanilla JavaScript won’t solve this problem entirely. You can still write huge JavaScript files or poorly written code without a framework.

But, libraries like jQuery can take quite a long time to parse, particularly on older mobile devices. Vanilla JS, with zero dependencies, still needs to be parsed, but effectively runs as soon as it hits the browser.

In my own experience, switching to vanilla JS from jQuery has had a huge impact on the perceived performance of the sites I build.