Skip to content

BB Snippets#

Custom CSS, JavaScript and HTML snippets for WordPress, printed on the pages their rules select. BB Snippets is a drop-in, data-compatible replacement for Simple Custom CSS and JS PRO, built by Brightbase to work with BB Cache and BB Migrate.

This documentation describes version 0.3.2.

What it does#

Part What it is for
Snippets CSS, JavaScript or HTML, printed in the head, after the opening body tag, before the closing body tag, or as a shortcode
Where on site Rules that pick the pages: all pages, the homepage, URL contains / is / starts with / ends with, exclusions, WordPress conditional tags
Placement Site, admin, login page or block editor; inline or as a linked file; order 1 to 10
Details A stable key, environments, an expiry date, owner and notes
Tools Test which snippets print on a URL, health checks, export and import
Theme files Snippets kept as files in the theme's snippets/ folder, deployed with the theme

What is different from the old plugin#

  • Snippets created or changed outside the edit screen (WP-CLI, imports, BB Migrate, revision restores, SQL) print immediately. The old plugin only noticed its own edit screen.
  • The database is the source of truth. Files are derived from it and refreshed.
  • Code prints exactly as written. The old plugin dropped backslashes when it rebuilt files.
  • A linked file's URL changes only when that file does, so one save no longer empties every cache.
  • Conditional rules are parsed, never eval()'d. Shortcode snippets never run PHP.
  • Snippet changes purge only the cached pages they affect.
  • Snippets can be limited to environments (so a staging-only snippet stays off production) and given an expiry date.
  • SASS and LESS are compiled once, when the snippet is saved; a snippet that stops compiling keeps its last good version.
  • Snippets can be theme files, reviewed in git and deployed with the theme.
  • A linked snippet can tell BB Cache to inline it in the page or keep it out (critical CSS).
  • Optional registered output: snippets become WordPress styles and scripts that themes can replace by handle.

Where to go next#