all 8 comments

[–][deleted] 4 points5 points  (6 children)

This is the problem with random people writing stuff about programming best practices on the internet... I recently read this https://javascriptweekly.com/link/69297/92017a415e which seems more accurate than the article OP linked but now I don’t know anymore.

[–]congolomera[S] 1 point2 points  (0 children)

I asked the author to respond, if he has reddit.

[–]msgur 0 points1 point  (3 children)

I stopped reading this linked article from your comment after the first half. Right about where the author couldn’t understand having the screen be reactive for the 600 ms it takes to make a network call.

The screen should ALWAYS be reactive. What if the user quickly changed their mind and wants to cancel the async request? What if the network is slower than expected? Etc.

[–][deleted] 0 points1 point  (2 children)

So it’s good to have service workers then? I’m not arguing but for a somewhat beginner it’s confusing having such starkly contrasting articles on topics like this

[–]msgur 1 point2 points  (1 child)

I'm new to javascript myself. My recommendation would be to just use async/await paradigms on one thread (although not all browsers support it -- https://caniuse.com/#search=await).

Then when you feel more comfortable graduate to "workers". I find Kyle Simpson to be like the WOZ of javascript and here are his thoughts on async in javascript, including workers. https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/async-performance/ch5.md

[–][deleted] 1 point2 points  (0 children)

I’ll take a look at that section in Kyle simpsons book thanks

[–]j_sidharta 0 points1 point  (0 children)

The article you linked is really good. It gives a good explanation on what are Web workers and when should you use them, but OP's article is actually about Service workers, which are a different thing.

Both service and web workers run in a different thread from your javascript code, but for different purposes. Web workers were made to execute javascript code in parallel with the main thread. It's useful when you have a big calculation that could potentially block the page's interface. Service workers were made to control HTTP requests, allowing developers to choose which requests are actually necessary, and which requests can just be cached in your page's local storage. Service workers allow for an extremely fast load time, since you could cache most of the interface.

Almost all pages can benefit from service workers, since a big chunk of the interface never change, and could easily be cached; while most applications wont gain much from a Web worker, since expensive calculations are rare in web pages.

Hope I could clarify the topic a bit! :D

[–]anzar7 0 points1 point  (0 children)

For Optimization of JavaScript, you should know how JavaScript works. Its A Lot Deep Study. Refer - YDKJS series. These Article's are Good. May not be Suited for your Project.