Pixboost / har-jq-cheatsheet

Cheat sheet for extracting information from HAR files using JQ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

har-jq-cheatsheet

Cheat sheet for extracting information from HAR files using JQ.

HAR is "HTTP Archive" that contains detailed information about requests and responses.

To get HAR file:

  • Open Google Chrome Dev Tools on the page (F12)

  • Go to "Network Tab"

  • Right click -> Copy -> Copy all as HAR

  • Paste into a new JSON fil.

  • Listing all images with size and times

.log.entries[] | 
  {"url": .request.url, "time": .time, "size": .response.content.size} | 
  select(.url | match("png|jpg|PNG|JPG|jpeg|JPEG"))
  • Count all images requests
[
  .log.entries[] | 
  select(.request.url | match("png|jpg|PNG|JPG|jpeg|JPEG"))
] | length
  • Count total time for all loaded images including queueing
[
  .log.entries[] | 
  select(.request.url |
    match("png|jpg|PNG|JPG|jpeg|JPEG")
  ) | {time: .time}
] | reduce(.[]) as $i (0; . += $i.time)
  • Count total time for all loaded images without queueing
[
  .log.entries[] |
  select(.request.url |
    match("png|jpg|PNG|JPG|jpeg|JPEG")
  ) | {time: .time, t: .timings} 
] | reduce(.[]) as $i (0; . += ($i.t.receive - $i.t._blocked_queueing + $i.t.send + $i.t.wait + $i.t.blocked))
  • Count number of bytes transferred by images
[
  .log.entries[] |
  select(.request.url |
    match("png|jpg|PNG|JPG|jpeg|JPEG")
  ) | {r: .response} 
] | reduce(.[]) as $i (0; . += $i.r._transferSize)

About

Cheat sheet for extracting information from HAR files using JQ

License:MIT License


Languages

Language:Shell 100.0%