I have got two Report Widget classes both of which use highcharts.js
library. So both of them should include highcharts.js
before being rendered. Therefore they implement the loadAssets
method:
public function loadAssets()
{
$this->addJs('js/highcharts.js');
}
The problem is that I should not call addJs
method if another report widget has already been added to the page, otherwise highcharts.js
will be included in the backend dashboard twice. How can I check to avoid adding the js file multiple times?
When using the
addJs()
andaddCss()
functions, October itself checks if the asset is already loaded and if it is, it is not loaded again.