css: load once for multiple blocks

Permalink
I've implemented a tooltip function on my custom block, and I load tooltip's css directly on block's header, with this line:
<link rel="stylesheet" type="text/css" href="css/tooltipster.css" />

The problem is that every block in the page loads this css, and it takes nearly one second to appear.
One workaround I've found is to put the contents of 'tooltipster.css' directly in the block's css. But, since I would to keep the 2 css separate, there's a way to load 'tooltipster.css' only one time, and not for each block?
(Moreover, I've the same problem with js scripts.)
Thanks!

 
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
You need to create an on_page_view() function in your block controller and load the css as a header item.
public function on_page_view() {
   $html = Loader::helper('html');
   $this->addHeaderItem($html->css('path/to/css/in/block'));
}