Your Choice JavaScript News

Node News Wednesday, March 14 Dom node, Arbitrary dom node, Particular request time & more…

Node News TLDR / Table of Contents

  • tsayen/dom-to-image
    • GitHub is where people build software. More than 27 million people use GitHub to discover, fork, and contribute to over 80 million projects.
    • DOM node, arbitrary DOM node, var node, raw pixel data, original DOM node
  • Properly measuring HTTP request time with node.js
    • Jacob Jedryszek is a Software Engineer who started and shipped Azure Mobile app, and helped Microsoft to build and ship the Azure Management Portal. He is also a speaker at conferences around the World.
    • particular request time, new Date, var request, actual time, external APIs
  • HTTP/2 Server Push with Node.js | @RisingStack
    • In this blog post, we will introduce the most important aspects of HTTP/2 Server Push and create a small Node.js app that gains benefit from using it.
    • server push, assets, HTTP header fields, small Node.js app, initial HTML file
  • dom-to-image is a library which can turn arbitrary DOM node into a vector (SVG) or raster (PNG or JPEG) image, written in JavaScript.
  • All the top level functions accept DOM node and rendering options, and return promises, which are fulfilled with corresponding data URLs.
  • Get a PNG image base64-encoded data URL and display right away: – – Get a PNG image blob and download it (using FileSaver, for example): – – Get an SVG data URL, but filter out all the elements: – – Get the raw pixel data as a Uint8Array with every…
  • Defaults to false – – A data URL for a placeholder image that will be used when fetching an image fails.
  • Defaults to undefined and will throw an error on failed images – – It’s tested on latest Chrome and Firefox (49 and 45 respectively at the time of writing), with Chrome performing significantly better on big DOM trees, possibly due to it’s more performant SVG support, and the fact that…

Tags: DOM node, arbitrary DOM node, var node, raw pixel data, original DOM node

  • When your backend code is calling external APIs you may want to measure particular request time to identify bottlenecks.
  • The most straight forward, but incorrect, way to measure how long request takes is to use JavaScript object: – – However, this wont give you the actual time that request takes.
  • Above request call is async, and you start measuring time at the time when request was queued, not actually sent.
  • In order to determine how much time elapsed since sending request, you can use the parameter: – – You can also compare results returned by both methods: – – When I run it, I got the following results: – – The actual time elapsed: 72 – – Time elapsed since…
  • Depending on your server side code, this difference might be even larger, and give you incorrect hints while you are profiling your application.

Tags: particular request time, new Date, var request, actual time, external APIs

  • The primary goals for HTTP/2 are to reduce latency by enabling full request and response multiplexing, minimize protocol overhead via efficient compression of HTTP header fields, and add support for request prioritization and server push.
  • HTTP/2 Server Push allows the server to send assets to the browser before it has even asked for them.
  • In HTTP/1 the client sends a request to the server, which replies with the requested content, usually with an HTML file that contains links to many assets (.
  • You can see that HTTP/2 multiplexing reduced the number of requests, and the assets were sent immediately together with the initial request.
  • You can find the full example here: Server Push, we can send assets to the browser before it has even asked for them to reduce the initial loading time for our users.

Tags: server push, assets, HTTP header fields, small Node.js app, initial HTML file

Top Node Courses

The Complete Node.js Developer Course (2nd Edition) (60,232 students enrolled)

By Andrew Mead
  • Build, test, and launch Node apps
  • Create Express web servers and APIs
  • Store data with Mongoose and MongoDB
  • Use cutting-edge ES6/ES7 JavaScript
  • Deploy your Node apps to production
  • Create real-time web apps with SocketIO

Learn more.


Angular (Angular 2+) & NodeJS - The MEAN Stack Guide (26,806 students enrolled)

By Maximilian Schwarzmüller
  • Build real Angular + NodeJS applications
  • Understand how Angular works and how it interacts with Backends
  • Connect any Angular Frontend with a NodeJS Backend
  • Use MongoDB with Mongoose to interact with Data on the Backend
  • Use ExpressJS as a NodeJS Framework
  • Provide a great user experience by using Optimistic Updating on the Frontend
  • Improve any Angular (+ NodeJS) application by adding Error Handling

Learn more.