Forums

Google PageSpeed Module

Is it possible to ilmpelement Google PageSpeed Module (https://developers.google.com/speed/pagespeed/module) on my Flask web application that I host on PythonAnywhere? What would be the most efficient way to do this?

Google PageSpeed looks pretty interesting! Unfortunately it won't work with our setup right now, but I'll add it to our list.

You can probably get a number of the same benefits by using a compressor module; that's what we do to speed up PythonAnywhere. We use Django, so the module we use for it is Django Compressor, but this Jinja compressor for Flask looks like it does a similar job.

The way they work is that you put the tags that include your static assets inside special template tags, then when your template is rendered, they hash all of the files you're including and put them into single minified files, so each page loads just one CSS file, one JavaScript file, and so on -- or at least, fewer files (depending on how you use the tags). The combined, minified files are stored on the filesystem in a place that your web app can write to and that is configured on the "Static files" part of the web tab to be served as static files.

One important thing is that things will work fastest on PythonAnywhere if you use a compressor that stores the compressed files on the filesystem -- ones that try to store stuff in memory are likely to be slower. So this one, which would probably work well on Google App Engine, won't work well here.