Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (2) | Download .zip | Reputation | Support forum (1) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2016-05-08 (5 months ago) | 51% | Total: 244 This week: 1 | All time: 7,455 This week: 1,047 |
Version | License | PHP version | Categories | |||
amp-remove-unsed-css 1.1 | Freely Distributable | 5 | HTML, PHP 5, Wireless and Mobile, Per... |
Collaborate with this project | Author | |
amp-remove-unused-css - github.com Description This class can be used to take away unnecessary rules within the CSS fpr AMP (Accelerated Mobile Pages). Innovation Award |
This class can be used to take away those unnecessary rules within the CSS code pages AMP (Accelerated Mobile Pages) format.
In this format each single page contain inline the whole CSS styles that will need.
Ok, all CSS in AMP is embeded inline, but some people still use templates styles with a tons of CSS code, and most of pages can add large extra useless CSS code.
It's time to reduce useless CSS and remove all those CSS rules not being used, leaving usually a few lines in each single page.
ˇNow we don't need to worry about big CSS templates that are being translated to AMP protocol!
These funcions will not significantly reduce the final download size once compressed, but will add clarity in code and will reduce the processor time, that it's useful in handheld devices.
Maybe in the future Google will mind the size of AMP pages and classify the smaller ones in a better position.
I tried some approaches to get the fastest algorithm, and now it's really fast. But I recommend to cache pages as usual.
More information about AMP: https://www.ampproject.org/
First include the file amp_remove_css.class.php
HOW TO USE - BASIC:
$tmp = new AmpRemoveUnusedCss();
$tmp->process($htmlcode); //must be full htmlcode, with <style amp-custom> tag and the <body> content
echo $tmp->result();
HOW TO VIEW REPORT:
$tmp = new AmpRemoveUnusedCss(1); //set 1 or TRUE to get full report, or void or 0 or FALSE to get simple report
$tmp->process($htmlcode);
echo $tmp->report();
ONLY MINIFY CSS (can be used in no-AMP pages, too)
You also can just only minify CSS by calling (it removes useless white spaces, but it does not remove unused CSS rules):
$tmp = new AmpRemoveUnusedCss();
$css_minified = $tmp->minify($css);
Files |
File | Role | Description |
---|---|---|
amp_remove_css.class.php | Class | Class source |
README.md | Doc. | Documentation |
amp-remove-unsed-css-2016-05-08.zip 4KB | |
amp-remove-unsed-css-2016-05-08.tar.gz 3KB | |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Ratings | User Comments (1) | ||||||||||||||||||||||||||||||||||
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.