Skip to content

Instantly share code, notes, and snippets.

@vinacms
Last active March 25, 2017 20:47
Show Gist options
  • Save vinacms/9f10e16bd63910210868b1320583e5da to your computer and use it in GitHub Desktop.
Save vinacms/9f10e16bd63910210868b1320583e5da to your computer and use it in GitHub Desktop.
############Google Fonts css to JS#########
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Roboto:400,700&amp;subset=latin-ext,vietnamese' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})(); </script>
#####Convert image to webp#########
apt install webp libwebp-dev
apt install parallel
find /var/www/html/optimize/images/themes -name "*.jp*g" | parallel -eta cwebp {} -o {.}.webp
####Enable cache browser#######
<FilesMatch ".(ico|pdf|flv|jpg|svg|jpeg|png|gif|js|css|swf|woff|webp)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment