Divi Code Snippets
Enhance your Divi designs with these simple bits of code
Mobile Snippets
Mobile Menu Links not Clickable (Requires to tap to go to the next page)
Add this code snippet to your Divi ePanel Integration Section.
<script>
var touch = window.ontouchstart
|| navigator.MaxTouchPoints > 0
|| navigator.msMaxTouchPoints > 0;
if (touch) { // remove all :hover stylesheets
try { // prevent crash on browsers not supporting DOM styleSheets properly
for (var si in document.styleSheets) {
var styleSheet = document.styleSheets[si];
if (!styleSheet.rules) continue;
for (var ri = styleSheet.rules.length – 1; ri >= 0; ri–) {
if (!styleSheet.rules[ri].selectorText) continue;
if (styleSheet.rules[ri].selectorText.match(‘:hover’)) {
stylesheet.deleteRule(ri);
}
}
}
} catch (ex) {}
}
</script>WooCommerce Snippets
Hide Product Tab's bar
Add this code snippet to your Divi Custom CSS section or into your Child Theme’s style.css
.tabs.wc-tabs{display:none;}Hide Related Products
Add this code snippet to your Divi Custom CSS section or into your Child Theme’s style.css
.woocommerce-tabs.wc-tabs-wrapper{margin-bottom:0px;}
.related.products{display:none}
#left-area{padding-bottom:0px;}.htaccess
Expires Headers
Expires headers let the browser know whether to serve a cached version of the page.
- Reduce server load
- Increase page load time
- Cost benefit ratio: high value
- Access needed to the .htaccess files or server administration files
Add this code snippet into your .htaccess file via FTP or File Manger from your cPanel.
# Enable expirations ExpiresActive On # Default directive ExpiresDefault "access plus 1 month" # My favicon ExpiresByType image/x-icon "access plus 1 year" # Images ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpg "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" # CSS ExpiresByType text/css "access plus 1 month" # Javascript ExpiresByType application/javascript "access plus 1 year"
Enable gzip compression
Reduce the size of files sent from your server to increase the speed to which they are transferred to the browser.
- Reduce sizes of pages by up to 70%
- Increase page speed
- Cost-benefit ratio: high
- Access needed to the .htaccess files or server administration files
Add this code snippet into your .htaccess file via FTP or File Manger from your cPanel.
<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>