Skip to content

Instantly share code, notes, and snippets.

View ossipov's full-sized avatar
🏠
Working from home

Dmitry Ossipov ossipov

🏠
Working from home
View GitHub Profile
@isaumya
isaumya / http2-server-push-nuxt-js.md
Created October 27, 2019 16:47
Add HTTP 2 Server Push to Nuxt JS Application (Universal Mode) - Tested in Zeit Now

How to do HTTP/2 Server Push in Nuxt.JS App (Tested in Universal Mode & Hosted in Zeit Now)

While developing my Nuxt.js app, the one thing I tried to do most was HTTP/2 Server Push, as I am hosting my app on Zeit Now which does support both HTTP/2 and Server Push. The main reason I wanted to do it was I was using Bootstrap Vue on my project. Whcih add the Bootstrap CSS + Bootstrap Vue's own custom CSS as inline style to the document which was making the document huge. Moreover in bootstrap vue you can do bootstrapCSS: false which will not add the Bootstrap's default CSS to your page, but it will add it's own custom CSS.

Also, in my nuxt have I had a lot of CSS at the component/layout level, which are also getting added to the document as inline style. It was getting crazy. At this point I can either load the bootstrap from a CDN which costed me another external request or I can host it myself (Zeit does have CDN) on my own CDN and then do HTTP/2 server push. So, that is what I diid. I also load a style