Here’s a practical idea which I have in use in a project of mine.
The idea I had was at first, make that function provide the minified version of the JS file if we’re not running
our application in debug mode. If we are on debug mode, server the normal file.
So, I added a minified option to that function above, which does just that.
There’s also a python version of it.
the routine only runs once.