Giter Site home page Giter Site logo

drab's Introduction

DRupal Aggregation Bundles (DRAB)

Drupal provides a system to automatically aggregate CSS and JS files. This is handy if you have a small site with a few CSS or JS files to be combined. If you are working on a larger site with aggregation turned on, this means you are getting CSS/JS for sections of the site that a person may never see.

What this module allows us to do is create a "bundle" off CSS/JS files in the theme .info file and have that bundle applied only to certian paths.

Example Use Case

Say you have a website for a large transportation provider like a airline or train service. You would get to the homepage and most people would want to start booking a ticket. The provider probably also has marketing/landing pages, user account management section, etc.

To optimize the amount of requests we can create a bundle for each section so instead of downloading the CSS/JS for the whole site which is more bandwidth they just get the correct aggregate files for the section they are in. These files can be stored in the browser cache like normal so if they leave the section and then come back the files doesn't need to be downloaded again.

How to create a bundle

Update your theme.info file with this array pattern

bundle[base][css][files][] = base/css/logos.css.less
bundle[base][css][files][] = base/css/gateway.css.less
bundle[base][css][files][] = base/css/dropkick.css.less
bundle[base][css][files][] = base/css/shared-panes.css.less
bundle[base][css][files][] = base/css/jquery.ui.theme.css
bundle[base][css][files][] = base/css/jquery.ui.tabs.css
bundle[base][css][path][] = all

bundle[booking_path][css][files][] = transaction/css/step-1.css.less
bundle[booking_path][css][files][] = transaction/css/step-2.css.less
bundle[booking_path][css][files][] = transaction/css/step-3.css.less
bundle[booking_path][css][files][] = transaction/css/step-4.css.less
bundle[base][css][path][] = book/flights/*

Caveats

This is for large sites that have descrete areas and not for small sites.

Because this is URL specific it makes it bit fragile. If some site editor comes along and changes the URL structure so it doesn't match the patterns in the info file the site could break quite badly

Inspiration

This module is took some inspiration/copied how the Modernizr added more information in to the theme info file

drab's People

Contributors

paulsheldrake avatar

Stargazers

 avatar  avatar

Watchers

 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.