smashingmagazine / redesign

Reporting bugs and weird issues on the shiny new Smashing Magazine.
https://next.smashingmagazine.com
41 stars 2 forks source link

JS dependency and `async` attribute mean racy failures are possible #283

Open yoavweiss opened 6 years ago

yoavweiss commented 6 years ago

1.js depends on app.js but both are loaded with the async attribute, meaning they can racily fail if app.js takes longer to load and 1.js loads faster.

While copying the new smashing redesign to my own server for testing purposes (I hope that's OK, but wanted to use real content for perf tests of https://chromium-review.googlesource.com/c/chromium/src/+/720798 :D), I got failures of 1.js, indicating that webpackJsonp is not defined. I noticed that in my setup 1.js loads and executes before app.js, resulting in that failure.

While on the production site I didn't see such failures, 1.js could load first if e.g. its host is having a bad day and takes longer to respond.

You could solve this issue by changing these scripts to defer even though that may have implications for IE8 support (I don't know if you actually support IE8). Alternatively, you can preload them, and execute both only after both are preloaded.

- Do you want to request a feature or report a bug? Bug

- What is the current behavior? Potential racy failures if app.js is slower than usual.

- If the current behavior is a bug, please provide the steps to reproduce.

- What is the expected behavior?

- Please mention your operating system version and the version of your browser

vitalyfriedman commented 6 years ago

Thanks for reporting it, @yoavweiss — will look into in detail next.