Responsive JavaScript in Rails: load what you need when you need it
pothibo.com
pothibo.com
In some ways, what I showed in the post is functional.
- Select a DOM i.e var $elem = $("#anElementId")
- Act on it i.e $elem.fadeOut()
It's not one or the other. It's one AND the other.
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.
I liked the idea and added a demo using Flask/Python as well :)
The talk is in french so you guys might want to skip the talk and jump to the code ;)
Disclaimer: I was one of the co-founders.
Performance wise, I've seen a significant increase in page load times.