

#MINIFY CSS WORDPRESS CODE#
If JS or CSS files are minified in a theme as part of a build process, include the source files for the purpose of code review. CSS files are minified as well as concatenated, which reduces file size by removing unnecessary white space. Naming the files style.css and style-test.css is often a best practice.By default, if enqueued, an application’s JavaScript and CSS files are concatenated in order to reduce the number of requests that occur on a single page load. Many developers keep both on their websites so that they can continue to make edits without having to try to read through a highly minified CSS file.

#MINIFY CSS WORDPRESS UPDATE#
Update colors to HEX and utilize shortened HEX codes where possible.Remove unnecessary semicolons left in the property array for each selector.Remove comments (if you’re on WordPress, leave the initial theme comments).Let’s put our actions in order so that you can check off each as you work to minify CSS: Be sure to test your stylesheet across multiple pages, browsers and a mobile device after you’re done – some of these automated tools can inadvertently remove styles that are critical for optimal viewing. There are several tools available that can help minify CSS, including CSS Compressor (used for our example above), CSSminifier and CleanCSS. Reducing your CSS by 31.89 percent is no small feat and can have a dramatic impact on your readership and even your ability to convert a visitor into a customer. Ultimately, minifying CSS is abbreviating CSS properties utilizing standard CSS rules and removing any unnecessary characters within the file. It’s important to keep in mind that there is no functionality loss when minifying your CSS file. Developers often leave an unnecessary semicolon on the last property-value when writing their declarations. Watch CSS notationsĬSS notation is a selector, followed by properties within parenthesis, separated by semicolons. Removing unnecessary CSS code like duplicate or unused declarations is one of the easiest ways to reduce your CSS file size. Be careful, though! Many times CSS declarations may be included for unique pages, tools, or media types that these tools can not identify. There are some tools on the web to identify declarations no longer in use. Over time, CSS files often become unruly and large as developers add CSS for different pages or integrations that may no longer be utilized. Ways to Minify CSS in WordPress Remove unnecessary CSS High - no readability and smallest file size (style-high.css).Moderate - moderate readability and smaller file size (style-moderate.css).Standard -maintains a balance between readability and smaller file size (style-standard.css).Low - maintains the high readability of your CSS (style-low.css).Original -this stylesheet has no minification (style.css).
#MINIFY CSS WORDPRESS DOWNLOAD#
You can download all the example files here.

We’re going to adjust our minification efforts at four levels of aggressiveness to show what the overall impact is. Some minification techniques are fairly simple – like removing notes and whitespace – and some are very aggressive – like utilizing shorthand. This is a fairly small CSS file already, but it’s not fully minified so we can shave off some of the load time. The original CSS stylesheet (style.css) is 102,951 bytes. Minifying CSS is the process of removing unnecessary characters from a CSS file, thus reducing the file size and increasing the speed at which a visitor can download your page.įor these examples, we’re going to utilize the famous Twenty Fifteen theme from WordPress. Media can be compressed, too, but that’s for another article. Minimizing the file size reduces the time for them to be downloaded.

In order to speed up your site’s loading time - especially on the first visit - it’s imperative that your HTML, CSS and JavaScript be written so that the files are as small as possible. This will slow your page loading times unnecessarily. The problem with style sections and inline styles is that they will be loaded every time with the page and never cached by the browser. A best practice is to remove or minify CSS references in your HTML - whether it’s a style section in the head of the page or inline styles applied throughout the page elements.
