Out of the box, this developer has a couple different options:
Use JSGroupings Extension
Adding script tags to page dynamically
You could add script tags to your Handlebars template or via a Sidecar controller. But this approach adds a bunch of ugly complexity to your code as you have to manage many routine tasks related to loading scripts.
Providing another way!
Sidecar Plug-in Framework
In Sugar 7, we introduced a plug-in framework that allows you to Mixin additional functionality into your Sidecar component with minimal fuss. If you have created a Sugar Dashlet before then you have already used the Dashlet Sugar 7 plug-in.
Under the Sidecar covers, the plug-in manager uses Underscore extend() to add properties from the plug-in to your component. In the case of the Dashlet plug-in, this adds the necessary APIs that Sugar needs to display and manage your view within Sugar Dashboards.
There are two important facts to keep in mind when working with Sidecar plug-ins.
Sidecar plug-ins are not extensible
You cannot extend a Sidecar Plug-in like you can a standard Sidecar component such as a view, layout, field, etc. So when creating Sidecar plug-ins, we recommend making them as lightweight and granular as possible so you can easily mix, match, and replace plug-in combinations in Sidecar components.
Sidecar plug-ins should be installed using JSGroupings extension
Also, we recommend registering your new custom Sidecar plug-ins using the JSGroupings extension. Below we will provide a couple of examples that shows more details on how this works.
Registering your Sidecar plug-in
Adding a plug-in to Sugar is as easy as calling app.plugins.register(). Lets break down the parameters.
app.plugins.register(name, validTypes, plugin)
|name||(String) Plugin name that you want to use|
|validTypes||(String|Array) list of component types this plugin can be applied to. Limited to view, field, layout, model, and collection as of Sugar 7.6.|
|plugin||(Object) Plug-in object|
Plug-ins are registered after the Sugar application has been initialized. When registering a plug-in using JSGroupings extension, you should do so within an app:init event handler. You will see this in both examples below.
To read the full Sidecar plug-in manager documentation, view the doc blocks in sidecar/src/core/plugin-manager.js.
Our CssLoader example is quite simple. The Css Loader plug-in is also available over at the Sugar Integration Building Blocks project in Github. It tracks the Stylesheets loaded in the browser and only adds a new link tag to pull in new CSS files as needed.
Highcharts and Unicorn Buttons Dashlet Example
Easy right? This is what it looks like when it is installed on a Sugar Dashboard.