unic / estatico

[DEPRECATED] Estático – Static site generator for frontend unicorns
Other
121 stars 18 forks source link

moved babel-polyfill from head.js to main.js #64

Closed swey closed 7 years ago

swey commented 7 years ago

moved babel-polyfill from head.js to main.js (to reduce head.js' file size)

At the moment there is no need for the polyfills in the head. If there is one in future, it will be better to pick the specific objects/functions from core-js.

(In future it also could be helpful to have a custom polyfill build (with selected core-js objects/functions) in main.js instead of including the whole package.)

backflip commented 7 years ago

Are you sure this is not needed? I would kinda expect Babel to generate a head.js which old browsers do not understand. But I did not check.

swey commented 7 years ago

FontLoader and Helper don't have any special ES5/ES6 functionality which needs polyfills https://github.com/unic/estatico/blob/develop/source/assets/js/helpers/helper.js https://github.com/unic/estatico/blob/develop/source/assets/js/helpers/fontloader.js

backflip commented 7 years ago

Yay, thanks to the Netlify integration (see "checks" below) I was able to quickly test this build on IE9. https://deploy-preview-64--estatico.netlify.com/demo/modules/slideshow/slideshow.html looks fine, so I guess this makes total sense! I was not sure whether Babel would attempt to optimize things by rewriting them to use new APIs.

backflip commented 7 years ago

Btw: @marbor3 was playing aorund with core-js at one point, if I remember correctly.

backflip commented 7 years ago

@oriol, looks like the failing tests are due to the bug which was fixed in https://github.com/unic/estatico/commit/a1007f95ad626aaa9eb16888c3dac434965e71af

When I merge develop into @swey's branch, everything works fine. Tested in IE9 and friends.

backflip commented 7 years ago

Thanks a lot, @swey, render-blocking JS reduced by a whopping 90%!

swey commented 7 years ago

By the way: Loading the main.js async has also a big effect on the page load time. (But this change has some dependencies, I try to create a PR soon.)

backflip commented 7 years ago

@swey Possibly ignorant question: How would this help since we already load main.js at the bottom of the page where it can't really block anything anymore? Or do you see an advantage in domcontentloaded being fired before main.js was loaded?

swey commented 7 years ago

Even if the main.js is loaded on the bottom of the body, it technically blocks the rendering of the page. (The rendering is blocked until the script is fully loaded if it is loaded synchronous.)

Besides the heavy effect on Google's PageSpeed value it sometimes also causes bugs. E.g. we had a case were we readout the height of an element in the synchronous main.js but the returned value was wrong because the page rendering was not finished yet.