Skip to content

Load Assets Faster!

Compare
Choose a tag to compare
@nimaa77 nimaa77 released this 25 Apr 20:46

We Skipped version 2, there was a problem with our deployments to npm so a canary release tagged as a stable release and ...

Load Assets Faster!

Upgrading to version 3 should not take more than 10 minutes.

In v1, with asyncComponent you split part of your application into a new chunk, and on BROWSER when you need that part of your code it gets downloaded automatically. when page rendered on the server there was no way to understand which chunks needed for the current request so After.js only sends client.js and styles.css file, then on BROWSER with ensureReady method it tries to fetch chunks (split CSS and JS files) needed for the current request. and it's slow!

WHY?

  1. browser must download client.js, then parse it and at the end, it executes the code. when code gets executed ensureReady method gets called, ensureReady finds and download chunks needed to render the current page and when all files get downloaded it start to re-hydrate.

  2. browser will render the page without CSS styles (because we split them and it will get them when ensureReady called), this makes the site look ugly for 2,3 seconds (bad UX).

  3. have you ever think about why CSS is render blocking?
    if browser finds a <link rel="stylesheet"> tag, it would stop rendering page and waits until CSS file be downloaded and parsed completely (this mechanism is necessary to have fast page renders), if CSS files attach to dom after page gets rendered, the browser must repaint the whole page. (painting is too much job for browser and it's slow)

in After.js 2 this problem is solved and it sends all JS and CSS files needed for current requests in the initial server response.

READ MORE

Major Changes

  • Chore: update examples for new version: 0339d4f
  • V3: #323

Minor Changes

Patches