Giter Site home page Giter Site logo

silasmariusz / tinyfier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ideatic/tinyfier

0.0 2.0 0.0 5.55 MB

Complete suite for compressing, preprocessing, and optimizing HTML/Javascript/CSS and Images.

Home Page: http://www.tinyfier.com

ApacheConf 0.31% PHP 83.81% CSS 8.70% JavaScript 0.52% HTML 6.67%

tinyfier's Introduction

Tinyfier

Tinyfier is a complete suite for compressing, preprocessing, and optimizing HTML/Javascript/CSS and Images.

Usage

Optimization on-the-fly (assets_loader)

With Tinyfier you can combine multiple CSS or Javascript files, add extra functionality to CSS (using LESS), remove unnecessary whitespace and comments, and serve them with gzip encoding and optimal client-side cache headers.

For compress and combine your javascript and stylesheets files, all that you need to do is replace the original URL:

http://example.com/static/stylesheet.css

By this:

http://example.com/static/tinyfier/tinyfier.php/stylesheet.css

You can also join multiple files into a larger one, reducing the number of HTTP request and making your application fly!

http://example.com/static/tinyfier/tinyfier.php/main.css,user.css,print.css

Also, if you want to pass extra variables to CSS parser, you can do it by adding it into the URL, for example:

http://example.com/static/tinyfier/tinyfier.php/stylesheet.css,base_color=%23ff0000 http://example.com/static/tinyfier/tinyfier.php/stylesheet.css,height=450

Javascript

Tinyfier uses the Google Closure service to compile and minimize Javascript, and, if not available, rely on JSMinPlus for that operation.

CSS

For CSS files, Tinyfier uses the lessphp parser by leafo for add extra functionality to css files. This include variables, mixins, expressions, nested blocks, etc. You can see all the available commands in lessphp documentation. Also, the generated css code is optimized, compressed and the CSS3 vendor prefix (like -webkit or -moz) are added, using css_optimizer.

Also, Tinyfier adds even more functionality:

Sprites

With Tinyfier, create a css sprite it's easy and intuitive. All that you need to do use the function sprite where the first argument is the image path (relative to the document) and the second the name of the sprite. E.g.:

.login {
    background: sprite('images/user_go.png', 'user') no-repeat;
}

.logout {
    background: sprite('images/user_delete.png', 'user') no-repeat;
}

Gradient generator

Tinyfier include tools to generate CSS3-compatible gradients with backward compatibility with old browsers (through the generation of the equivalent images).

header {
    background: gradient('vertical', @header_start_color, @header_middle_color 50%, @header_end_color, 1px, 200px);
}

(Remember that with lessphp you can use variables everywhere in your code!)

Image embedding

You can also embed images in the document (using the Data URI scheme) with the command inline.

#gplus {
   background: inline('images/social/gplus.png');
}

Image filters

Another cool function of Tinyfier is the ability for work with image filters.

#lion:hover {
   background: filter('images/lion.jpg', 'brightness', 50%);
}

Internally, Tinyfier uses the php function imagefilter, so you can use all the filters available for it (negate, grayscale, brightness, blur, pixelate and more).

Resize images

If you have to show your image or sprite in differents size, it's as easy as use:

#lion:hover {
   background: resize('images/lion.jpg', 50%);
}

The filter resize can take up to 4 arguments: image url, width (in either px or %), height, and a boolean value than enables or disables aspect ratio (true / false)

More

Please, look in the test file for more examples for using Tinyfier in your project. It's really easy!

tinyfier's People

Contributors

javiermarinros avatar dazag avatar

Watchers

James Cloos avatar Silas Mariusz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.