wiki:DeveloperGuidelines/Minify

Version 9 (modified by Fran Boon, 8 years ago) ( diff )

--

Minify

Table of Contents

  1. Foundation
    1. Old

Browsers default to only downloading 2 files from the same origin at a time, so many files is very slow on high latency links.

We therefore consolidate into fewer, larger files when running in Production mode.

Although, note that iPhone 3.x cannot cache files larger than 15kb and in iPhone 4 the limit is 25kb. And this is the size before gzipping.

Since GIS is a specialised app which requires many files, it's JS is loaded separately when required.

The build script is static/scripts/tools/build.sahana.py

It needs to be run as a web2py script:

python web2py.py -S eden -M -R applications/eden/static/scripts/tools/build.sahana.py

There is also a convenience wrapper for Windows to run this: static/scripts/tools/build.cmd

You must have an internet connection to run the build script unless you have a local version of the Compiler.

Our build process is based on the one used by OpenLayers

This uses Google's Closure compiler to compress the JS. This is done using their web service, however for OpenLayers itself we need to download the jar file & place in the tools folder since this is over 1Mb:

ToDo: Investigate using other options instead:

ToDo: Download/execute scripts asynchronously:

Foundation

To update to a new version of Foundation:

For the default Theme and each Theme with a custom Foundation build (eden/static/themes/THEME/scss):

  • Update foundation.scss
    • Backup the existing file & copy in the new file
    • Modify paths: @import '../../foundation/scss/components/
    • Comment the same lines in a copy of the new file & check that component names haven't been changed
  • Update _settings.scss
    • Backup the existing file & copy in the new file
    • Modify path: @import "../../foundation/scss/functions";
    • Copy the uncommented lines from the backup to the new file & check that variable names haven't been changed
  • Build foundation.css & foundation.rtl.css
    cd eden/static/themes/THEME/scss
    compass compile
    
  • Build foundation.min.css & foundation.rtl.min.css
    compass compile -e production
    

Old

  • set Max-Width to 125em
  • download 1 version with left-to-right (foundation.css/foundation.min.css), and one version with right-to-left support (foundation.rtl.css/foundation.rtl.min.css)

For custom SCSS builds:

  • Python libsass requires installing Visual Studio Express on Win32 currently, so the code in build.sahana.py isn't tested
  • Separate the core Foundation (foundation.scss) from the custom styles (style.scss)
  • For the custom style.scss, @include any required Foundation mixins, but omit the HTML classes using:
    $include-html-classes: false;
    $include-html-global-classes: false;
    
  • Build CSS using Ruby SASS:
    cd eden/modules/templates/MYTHEME/scss
    sass foundation.scss ../../../../static/themes/MYTHEME/foundation.css
    sass style.scss ../../../../static/themes/MYTHEME/style.css
    
Note: See TracWiki for help on using the wiki.