![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Minifies HTML, JavaScript, and CSS, including inline JavaScript and CSS.
CSS minification is handled by Sassc whereas JavaScript minification is handled by Uglifier which requires node.js.
HTML minification is handled as follows. First, an HTML 5 (which really means
the WHATWG HTML living standard)
parser constructs a DOM as specified by the standard. Next, semantically
meaningless inter-element whitespace
nodes
are removed from the DOM and semantically meaningfull runs of whitespace are
compressed to single spaces, except in pre
, textarea
, and
foreign elements.
Then, inline JavaScript and CSS are compressed using Sassc and Uglifier.
Finally, the DOM is serialized, compressing
attributes
where possible and omitting optional start and end
tags where
possible.
Unlike some other HTML minifiers, Squoosh uses neither Java nor regular expressions to parse HTML.
Squoosh will not minify
HTML 4 and XHTML documents (more precisely, any document that does not have an
HTML 5 DOCTYPE, typically <!DOCTYPE html>
) is returned unchanged by
Squoosh::minify_html
.
MathML and SVG elements have their tags minified (including compressing attributes and serializing empty elements as self-closing start tags) and comments inside them are removed. White space is preserved (except for the newline normalization performed by the HTML 5 parser).
Add this line to your application's Gemfile:
gem 'squoosh'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install squoosh
You can read the documentation here.
The three basic minification functions are
Squoosh::minify_html
Squoosh::minify_js
Squoosh::minify_css
The Squoosher
class caches (in memory) minified JavaScript and CSS which can
significantly speed up minifying HTML with repeated scripts and style sheets.
Create a _plugins/squoosh.rb
file with the contents
# frozen_string_literal: true
if Jekyll.env == 'deploy'
require 'squoosh'
squoosher = Squoosh::Squoosher.new
Jekyll::Hooks.register(%i[documents pages],
:post_render, priority: :high) do |doc|
case File.extname(doc.destination('./'))
when '.html', '.htm'
doc.output = squoosher.minify_html(doc.output)
when '.js'
doc.output = squoosher.minify_js(doc.output)
end
end
end
CSS minification could be handled similarly, or foo.css
files could simply
be renamed to foo.scss
and
sass:
style: compressed
added to _config.yml
.
Bug reports and pull requests are welcome on GitHub at https://github.com/stevecheckoway/squoosh.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that squoosh demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.