How to add an "onload" attribute to css links as like as generated by advagg in Drupal 7

106 views Asked by At

I want to add attribute rel ='preload' and onload="this.rel='stylesheet'" as done in advagg ?I have done in hook_css_later function but no luck . Here is my code

function page_speed_css_alter(&$css) {


        foreach ($css as $key=>&$item) {
            if (file_exists($item['data'])) {
                $item['preprocess'] = FALSE;
                $item['attributes']['rel'] = "preload";
                $item['attributes']['onload'] = "this.rel='stylesheet'";
            }
        }
}
1

There are 1 answers

1
mikeytown2 On BEST ANSWER

You’ll have to patch core if you don’t want to use advagg. Any reason why you don’t want to use it?