Are there libraries to package and minimize multiple CSS and JS files per file?

According to O'Reilly High-Performance Websites (pages 15-16), it is highly recommended that you make as few HTTP requests as possible for high-performance. So, is there a library for combining several JS files into one file, and also a library for this for CSS?

For JavaScript, I now have at least 4 different libraries, jQuery 1.6.x, several jQuery plugins and one application JavaScript file for the application logic. I also have 2 CSS files, Bootstrap and my application CSS file.

Are there any tools to facilitate this? It would be nice to have a tool that I could use with Python or from Bash (I'm on Linux) to “compile” and minimize a few CSS stylesheets.

(If this is possible as a Django addon, even better [ie manage.py packify static/bootstrap.min.css static/application.css ... ])

+6
source share
5 answers

What you are looking for is a css and javascript pipeline. This is becoming the standard for frameworks to provide these kinds of tools. For example, Rails 3.1 has a built-in native resource pipeline.

Not only will it combine your css and javascripts into one package, but it also compresses them to further improve performance.

Fortunately, django also has its own plugin for this.

https://github.com/cyberdelia/django-pipeline

+7
source

Of course, there is such a tool! It is called webassets . And also goes well with Django .

website features

  • minimization (compression) of CSS and JS
  • Less CSS
  • SASS to CSS
  • compass

and etc.

+3
source

There are various methods. The great plugin is already mentioned by JavierIEH. But you can easily create it yourself using PHP or any other server language.

But you will get even more if you download jQuery and its plugins from the Google libraries API . It offers an abridged version of many libraries.

The advantage is that it will not use your server. Browsers will only make a limited number of simultaneous connections to the same server, so it allows your users to simultaneously load jQuery and native JavaScript.

And since many sites use Google libraries, these files may already exist in your visitor’s browser cache, speeding up the download even more.

+2
source

If you can live with a PHP tool, check out CSS-JS-Booster , which adds a few more tricks than simple minification. For example, embedding small images referenced by your CSS in CSS (data-uri / mhtml), etc.

0
source

Check out this python script. It is not built on a wireframe and can be easily integrated.

http://github.com/hkasera/minify

It also minimizes js as well as css files. It stores detailed log files illustrating errors and warnings. Hope this helps!

0
source

Source: https://habr.com/ru/post/899073/


All Articles