Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
This as a Ruby bridge to Sqwish by Dustin Diaz to compress CSS very efficiently.
Just install it:
$ gem install sqwish
Then use it like so:
require 'sqwish'
Sqwish.minify "div { color: red; } div { background: black; }"
#=> "div{color:red}div{background:black}"
You can also use the strict: true
flag (it defaults to false):
Sqwish.minify "div { color: red; } div { background: black; }", strict: true
#=> "div{color:red;background:black}"
In your Gemfile:
gem 'sqwish'
# or optionally:
gem 'sqwish', github: 'rstacruz/sqwish.rb'
In your config/environments/production.rb
:
config.assets.css_compressor = Sqwish
# or use strict mode:
config.assets.css_compressor = Sqwish::Strict
If you use Sass (or a similar preprocessor), you probably separate your CSS definitions into multiple files. In Sass, there are two ways to do this:
/* Method 1: @import */
@import 'common';
@import 'layout';
@import 'chrome';
@import 'pages';
This is very convenient, and efficient in space, but slow. If you change one Sass file, the rest will have to be recompiled. In big projects, you can be waiting up to 10 seconds after updating a simple style.
Which leads us to method 2:
/* Method 2: Sprockets require */
//= require common
//= require layout
//= require chrome
//= require pages
This is faster! Updating one will no longer re-compile the others! The only problem here is that styles may be duplicated in each file, say, if each file depends on a web-font. You can end up with:
/* Method 1's crappy output with YUI :( */
@font-face{font-family:'Montserrat';...}
body{font-family:Montserrat}
@font-face{font-family:'Montserrat';...}
.page h1{font-family:Montserrat}
...which YUI (Rails/Sprocket's default compressor) will not optimize for you.
Use Sqwish! It will remove those duplicate @font-faces for you and combine anything else that can be combined.
/* Method 2's nice output with YUI :D */
@font-face{font-family:'Montserrat';...}
body,.page h1{font-family:Montserrat}
Released under the MIT license.
FAQs
Unknown package
We found that sqwish demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.