Skip to content

Instantly share code, notes, and snippets.

View evemilano's full-sized avatar

Giovanni Sacheli evemilano

View GitHub Profile
@evemilano
evemilano / sw.js
Last active October 25, 2017 19:45
Service Worker
/*
* EVE Milano sw.js
* Copyright 2017 Giovanni Sacheli All rights reserved.
* Version 1.2 (20 settembre 2017)
*/
self.addEventListener('install', e => {
console.log('PWA Service Worker installing.');
let timeStamp = Date.now();
e.waitUntil(
@evemilano
evemilano / Manifest.json
Last active October 25, 2017 14:03
Manifest.json
{
"short_name": "EVE Milano",
"name": "EVE Milano Consulenza SEO",
"icons": [
{
"src": "/wp-content/uploads/apple-icons/apple-touch-icon-48x48.png",
"type": "image/png",
"sizes": "48x48"
},
{
@evemilano
evemilano / absolute link
Created October 19, 2017 14:24
Absolute link
@evemilano
evemilano / relative link
Created October 19, 2017 14:23
Relative link
@evemilano
evemilano / Add this to the functions.php
Last active August 9, 2018 14:05
Add Defer & Async Attributes to many WordPress Script
function add_defer_attribute($tag, $handle) {
// add script handles to the array below
$scripts_to_defer = array('jquery-migrate', 'hoverIntent', 'superfish', 'superfish-args', 'skip-links', 'wp-embed');
foreach($scripts_to_defer as $defer_script) {
if ($defer_script === $handle) {
return str_replace(' src', ' defer="defer" src', $tag);
}
}
return $tag;
@evemilano
evemilano / Add this to the functions.php
Last active October 18, 2017 09:17
Add Defer & Async Attributes to a single WordPress Script
function add_async_attribute($tag, $handle) {
if ( 'my-js-handle' !== $handle )
return $tag;
return str_replace( ' src', ' async="async" src', $tag );
}
add_filter('script_loader_tag', 'add_async_attribute', 10, 2);
//* If you want to use defer just replace async="async" with defer="defer".
//* You will need to change the handle which will be the first parameter of the enqueue method.
@evemilano
evemilano / Redirect m. to www (dedicated mobile to desktop)
Created October 4, 2017 09:57
Redirect m. to www (dedicated mobile to desktop)
# Esempio 1
RewriteCond %{HTTP_HOST} ^m\.esempio\.com$
RewriteRule ^\*$ http://www.esempio.com/*? [L,R=301]
# Esempio 2
RewriteCond %{HTTP_HOST} ^m\.esempio\.com$ [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^\*$ http://www.esempio.com/*? [R=301,NE,NC,L]
# Esempio 3
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
<ifModule mod_headers.c> Header set Connection keep-alive </ifModule>
@evemilano
evemilano / Magento Robots.txt
Created June 7, 2017 14:47
Magento Robots.txt
User-agent: *
Disallow: /admin/
Disallow: *price=*
Disallow: *dir=*
Disallow: *order=*
Disallow: *limit=*
Disallow: */catalog/*
Disallow: */catalogsearch/*
Disallow: */customer/*