Giter Club home page Giter Club logo

kirby-v2-scssphp's Introduction

SCSSPHP Plugin for Kirby 2

This is a preprocessor for SCSS files. Built using the scssphp library by Leaf Corcoran. This Kirby 2 plugin will automatically process SCSS files when changed. As an option, you can use this plugin to create 'critical CSS'.

Installing SCSS

  1. Copy folder ‘scssphp’ inside ‘plugins’ to Kirby’s plugins folder.
  2. Copy file ‘scss.php’ inside ‘snippets’ to Kirby’s snippets folder.
  3. Call the SCSS snippet with in your HTML head.
  4. Create a folder ‘scss’ inside Kirby’s assets folder.
  5. Create a file ‘default.scss’ and place it inside ‘assets/scss’.
  6. Make sure the folder ‘assets/css’ exists on your server.

Using SCSS plugin

After installing this plugin, 'assets/css/default.css' will be overwritten automatically. Make sure you backup your original CSS.

It is possible to create different SCSSs for each Kirby template. Just use the name of your template file for the SCSS file (e.g. 'article.scss' for 'templates/article.php'), and place it in 'assets/scss'. If no SCSS file for a template can be found, 'default.scss' will be used.

Critical SCSS (a.k.a. above the fold)

If you would like to improve the performance of your website, you can use the 'scss.critical.php' in combination with the 'scss.php' snippet. This part of the plugin is optional and still experimental. Using critical CSS means inlining any CSS that is used to render content directly visible when you open a page. Before you start using critical CSS, my advice is to read more about this concept on CSS Tricks or Google PageSpeed Insights.

Installing Critical SCSS

  1. Follow the instructions for installing SCSS.
  2. Copy file ‘scss.critical.php’ inside ‘snippets’ to Kirby’s snippets folder.
  3. Call the critical snippet with in your HTML head.
  4. Call the SCSS snippet with below your page footer instead of your HTML head.
  5. Create a file ‘default.critical.scss’ and place it inside ‘assets/scss’.

Using Critical SCSS

Everything in 'default.critical.scss' will be compiled and placed in your HTML head. All relative URLs in your critical SCSS will be automatically converted to the correct absolute URLs in your critical CSS.

This plugin does not (yet) detect which CSS should be placed in your critical CSS. Therefor you need to manually place or import SCSS that will affect everything that has a large chance to be directly visible 'above the fold' when loaded. Do not forget to include your SCSS utilities (e.g. mixins) and settings (i.e. global variables) in your critical SCSS file.

The critical CSS will be updated after you update 'default.critical.scss' or upload it to another server. Updating the critical CSS after uploaded to another server is necessary because the absolute URLs in your critical CSS need to be updated.

It is possible to create different critical SCSSs for each Kirby template. Just use the name of your template file for the critical SCSS file (e.g. 'article.critical.scss' for 'templates/article.php'), and place it in 'assets/scss'. If no critical SCSS file for a template can be found, 'default.critical.scss' will be used.

My advice is not to remove any SCSS from your main SCSS file 'default.scss'.

Compatibility

The scssphp library implements SCSS 3.2.12. It does not support the older SASS syntax or SCSS 3.3 features. As a result Bourbon 4.0 isn't yet supported, use Bourbon 3.2.x, which contains many of the 4.0 features, instead.

kirby-v2-scssphp's People

Watchers

Lee Tengum avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.