Skip to content

Manage Scripts and Stylesheets ​

Use this guide when you want to add a sitewide script or stylesheet — a snippet that runs on every rendered page of your community, or on a specific page — and register it with gsds so the change is tracked in extensions_registry.json.

Scripts and stylesheets are Extensions alongside Custom Widgets. Unlike widgets, they inject globally on the page rather than rendering inside the No-Code Builder.

Choose a subcommand ​

gsds script and gsds style share the same shape:

You want to...Use
Create a local file in your repositorygsds script new or gsds style new
Register an external hosted URLgsds script link or gsds style link
List everything currently registeredgsds script ls or gsds style ls
Remove an entrygsds script rm or gsds style rm

Add a local script or stylesheet ​

sh
gsds script new analytics-tracker
gsds style new brand-overrides

new scaffolds the source file in your repository and adds an entry to extensions_registry.json. Edit the file, then run gsds build to confirm the registry entry still resolves to it.

Register an external URL ​

sh
gsds script link https://cdn.example.com/analytics/v1/tracker.js --name analytics-tracker
gsds style link https://cdn.example.com/themes/brand.css

link registers a hosted URL rather than a local file. The URL is the positional argument and must end in .js for scripts and .css for stylesheets. Pass --name to override the slug that gsds derives from the URL.

FlagPurpose
--attr k=vAdd an HTML attribute to the injected tag (repeatable). For a valueless attribute such as defer, pass the name alone: --attr defer
--page <name>Scope the asset to a specific page instead of the whole site (repeatable; identical values collapse to one rule)
--placement head|bodyStart|bodyEndWhere to inject the script tag. Scripts only
--name <slug>Explicit slug. Available on link only

Scope an asset to one page ​

Sitewide is the default. Pass --page to inject on a specific page only:

sh
gsds script new page-analytics --page product-tour --placement bodyEnd

List and remove entries ​

sh
gsds script ls
gsds style ls

Removing a named entry:

sh
gsds script rm analytics-tracker
gsds style rm brand-overrides

rm refuses to delete a folder with contents. Pass --force to delete a non-empty folder.

Handle registry drift ​

If a registered script or stylesheet points at a file that no longer exists, gsds build refuses to write the registry until you fix it. You have two ways out:

  • Restore the missing file, or
  • Remove the stale entry with gsds script rm <name> or gsds style rm <name>

gsds create warns on the same drift without failing so you can still scaffold new widgets while cleaning up.

Next steps ​

Gainsight CC Developer Portal