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.
Ok, the first thing you should do, is download a copy of the python version of JSMin, save it inside the lib directory of your project, and, on your project helpers file, have the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
Now, on your templates, all you have to do is:
Hope the has helped you in some way. Happy coding and Happy New Year!!!!
Update on 2008/01/02
Changed function to also combine the several JS files into a single one to reduce requests, just pass combined=True.
Commentscomments powered by Disqus