3 ms·
Of course, the drawback of this approach is that you're now sending javascript with every request. If you had done the traditional approach of sending your j
by bryanlarsen 13y ago
Of course, the drawback of this approach is that you're now sending javascript with every request. If you had done the traditional approach of sending your javascript in one big minified chunk it only needs to be sent once and your browser will load it from cache on subsequent requests.
- pothibo 13y agoYou are right, and I quickly went over it because I was scared of loosing the focus of the post by explaining into details many small parts. This is a balance you have to consider. If a user never clicks on the link, this method has an advantage over minifying everything since you would load the JS without using it. On the other hand, if a user keeps clicking the link while being on the same page (Important to stay on the same page), it would be better to have it stored in your minified chunk. It's a low hanging fruit optimization that can be very useful IMO.