Finding Unused CSS – Chrome Audit Panel

After you develop a site or web based content there is likely unused CSS (code detritus) in your files. We find for performance and maintenance purposes it is best practice to remove this unused code from your project.

To find unused CSS we use the Audit panel in the Chrome browser. With the Audit panel you can analyze a page as it loads. The audit output then provides suggestions and optimizations.

To generate a CSS audit open the Audit panel (View->Developer->Developer Tools->Audit). On the panel select the Web Page Performance audit, and Reload Page and Audit on Load, then click Run. Unused CSS is detailed in the Remove unused CSS rules list.

TechNote #44

WordPress Backup – UpdraftPlus

To ensure WordPress site safety, it is essential to have a good, automated, backup strategy. Our plugin of choice for this is the UpdraftPlus plugin (https://wordpress.org/plugins/updraftplus/). UpdraftPlus has a simple interface and is easy to use. And the free version will likely work for many people.

An important feature of the UpdraftPlus plugin is the option to save your backup files to a number of different cloud services (e.g., Google Drive). In case there is ever an issue with your hosting service, having your backup storage separate from hosting gives you an extra bit of security.

As an aside the quality of WordPress plugins varies greatly. Always check the number of downloads, update history, and ratings of the plugins you are considering. You want a highly rated plugin that is used by lots of people and is frequently updated. A poor quality WordPress plugin can be a source of security holes. Be discriminating about what you install on your site.

TechNote #43

Adding Command Line Tools to BBEdit

BBEditWe use BBEdit for a good portion of our html/css/javascript production work. Like many OS X applications BBEdit allows you to execute Applescript from its script menu. This makes it very easy to add command line tool support (e.g., linters, minimizers, compilers) to the application.

In the example below the Applescript will run the Google Closure Compiler (see TechNote #36) on the saved version, of a javascript file, open in the front most document window. If there are errors the Applescript try block will direct the output to a new BBEdit document window.

To make this script available to BBEdit simply place your .scpt file in BBEdit’s Scripts Folder. For more info about scripting BBEdit see the application documentation. To get started with Applescript see TechNote #4.

tell application "BBEdit"
	set jsfile to file of text document 1
end tell

process_item(jsfile)

on process_item(this_item)
  set theFile to quoted form of the POSIX path of (this_item as text)
  set the item_info to info for this_item
  set ext to the name extension of the item_info
  set i to length of ext
  set nam to the name of the item_info
  set j to length of nam
  set nam to text 1 thru (j - i - 1) of nam
  set dir to the POSIX path of (this_item as text)
  set k to length of dir
  set dir to text 1 thru (k - j) of dir
  set outFile to quoted form of the POSIX path of (dir & nam & "_compiled." & ext)
  set theFile to quoted form of the POSIX path of (this_item as text)
  set AppleScript's text item delimiters to " "
  try
    do shell script "java -jar /Applications/Utilities/closure/compiler.jar  --js_output_file=" & outFile & " " & theFile
  on error errorMessage
    tell application "BBEdit"
      set dest to make new text document
      set text of dest to errorMessage
      set name of dest to nam & "." & ext & " -- " & "Closure compiler errors"
    end tell
  end try
end process_item

TechNote #41