Search code examples
requirejshttp2

Does RequireJS support HTTP/2?


I've tried to find a clear answer on this, but unable to find it: Does RequireJS support the benefits of HTTP/2? While most browsers support HTTP/2 (for HTML documents, images, scripts, etc) most JavaScript engines in those browsers seem not, and with that, RequireJS would also lack HTTP/2 support - at least to my understanding. Additionally, EcmaScript 6 would introduce HTTP/2 support (somebody said), but I'm not able to find much on that topic either. Anybody is able to explain this more clearly?


Solution

  • There is no direct relationship between RequireJS and HTTP/2. Which means HTTP/2 needs to be implemented by the browser, not the library nor the JavaScript engine.

    On a more practical note, it's ok to use RequireJS with an HTTP/2 website, provided you have reasons to use RequireJS of course. Here is a tutorial:

    https://www.shimmercat.com/en/blog/articles/angular-push/