Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/mwat56/cssfs

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/mwat56/cssfs

  • v0.2.7
  • Source
  • Go
  • Socket score

Version published
Created
Source

CSSfs

golang GoDoc Go Report Issues Size Tag License


Purpose

Cascading Style Sheets (CSS) needed a long time to become browser independently usable. In this long time the capabilities seem to have grown almost beyond recognition. One thing, however, that didn't change over the last 25 years is the fact that in the end a style sheet is just a plain old text file. Sure, there is some sort of grammar and a certain vocabulary; but it all boils down to lines/paragraphs, preferably nicely formatted to make it easy to read and edit.

Easy, that is, for humans. For the machines (browser) almost all of the tabs, spaces, and linebreaks used to format a style sheet are just white space eating memory, white noise to be removed – or at least actively ignored – during reading and interpreting the file.

Additionally, that white space – during transfer – uses bandwidth and hence time and energy. So, getting rid of all those unneeded characters in the style sheet before transmitting it to the end-user (browser) saves both time and money for all parties involved. And that's the whole purpose of this little package: To remove the unneeded characters from a style sheet.

Installation

You can use Go to install this package for you:

go get -u github.com/mwat56/cssfs

or you can just include it directly in your own server's code base

import "github.com/mwat56/cssfs"

Usage

This package exports a single function FileServer(). So, while you're used to call

myCSSDirectory := "./css"
myCSSHandler := http.FileServer(http.Dir(myCSSDirectory)))

to create a fileserver for your static CSS files now, to use this implementation, you'd just do:

myCSSHandler := cssfs.FileServer(myCSSDirectory)

That's all.

Internally, whenever a CSS file is requested this package's fileserver checks whether there's already a minified version available and, if so, serves it. Otherwise it creates the minified version from the original CSS file to be used for this and all following calls.

Caveat

This package expects wellformed CSS files. If you find problems – i.e. incorrectly minified CSS – please let me know (e.g. file an issue).

Licence

    Copyright © 2020, 2022 M.Watermann, 10247 Berlin, Germany
                    All rights reserved
                EMail : <support@mwat.de>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

You should have received a copy of the GNU General Public License along with this program. If not, see the GNU General Public License for details.


FAQs

Package last updated on 16 Mar 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc