According to O'Reilly's High Performance Web Sites (pages 15-16), it's highly recommended to make as few HTTP requests as is possible for high-performance. Thus, is there a library for combining multiple JS files into one file, and a library to do this for CSS as well?
For JavaScript, I have at least 4 different libraries being loaded right now, jQuery 1.6.x, a few jQuery plugins, and one application JavaScript file for application logic. I also have 2 CSS files, Bootstrap and my application's CSS file.
Are there tools to facilitate this? It'd be nice to have a tool I could use from Python or from Bash (I'm on Linux) to "compile" and minify the multiple CSS stylesheets.
(If this is possible as a Django addon, even better [ie manage.py packify static/bootstrap.min.css static/application.css ...
])
To minify CSS, try CSSNano and csso. To minify JavaScript, try UglifyJS. The Closure Compiler is also very effective. You can create a build process that uses these tools to minify and rename the development files and save them to a production directory.
Click on wwwroot folder, select the css file you want minified, then right click and choose bundler & minifier. Then from popup minify file. It will be the same file name with the minified version.
gulp-minify-css - npm.
What you are looking for is a css and javascript pipeline. Its becoming a standard for frameworks to provide this kind of tools. For instance, Rails 3.1 has its own asset pipeline built-in.
Not only it will merge your css and javascripts into a single pack, but it will also compress them for even further performance boost.
Fortunately, django also has its own plugin for that
https://github.com/cyberdelia/django-pipeline
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With