What a web developer needs to know about http/2?

HTTP/2 is coming. Those who dont know what HTTP is, HTTP is the fundamental networking protocol that powers the web. The majority of sites use version 1.1 of HTTP. The new version of the protocol named HTTP/2 or HTTP 2.0. HTTP/2’s primary changes from HTTP/1.1 focus on improved performance.

In this article I will only discuss what a developer needs to know about http/2 to improve performance. If you have queries about implementation or other, you may check HTTP/2 FAQ or follow official twitter handle @http_2.


Combining multiple images into one image, and using CSS or javascript to only show part of that image.

HTTP/2 has a multiplexing feature that can deliver more HTTP requests at once. So dont load unnecessary resources. Suppose In a single page you are using 5 small images from a sprite which has combined 20 images. So unnecessary 15 small images you are loading which will increase a request time for a single file. Rather load your image on demand for each page.


Loading images through css background url or data: URLs property.

As I said in HTTP/2 its always better to load images ondemand, Suppoose in your css file your are loading 10 images using css background url property, but in a single page you need only using 3 images, So no need to increase request time by others 7 images which you are not using in current page.


Taking multiple css or javascript script and merging them into single large file.

Dont merge two or more css or javascript file into one. Load your script on page basis.
Suppose, you have two page file1.html & file2.html, both have common js file common.js.
common.js contains two script, one for file1.html & another for file2.html. So your are loading redundant code through common.js, Better you should use two js files for each page.


Using different domains, sub-domains to host assets like images or any other media files.

Resources from a separate domains or sub-domains that doesn’t use any cookies, as the size of cookies these days can be increase requests time. While loading static resources like images, css, js files cookies aren’t required.

If you use a new domain or sub domain then you can increase the amount of simultaneous connections to load your files. Thus, you can fetch the website assets faster.


So In HTTP/2 you need to reduce HTTP requests time for each request than the number of HTTP requests.
Some further reading here:

HTTP/2 Draft Specifications
​How HTTP/2 will speed up your web browsing
Everything You Need To Know About HTTP2