Forum

Thread tagged as: Question, Feathers

How can I make a script async through Feathers?

I can successfully load scripts through Feathers following the tutorial but wondered, what is the best way for me to make them load async?.

I've got as far as this:

if (!$this->component_registered('script')) {
    $out[] = $this->_script_tag(array(
        'src'=>$this->path.'/js/script.js',
        'async'=>$this
    ));
    $this->register_component('script');
}

Which produces this:

<script src="/perch/addons/feathers/default/js/script.js" async="" type="text/javascript"></script>

but it's not quite right and I get the following error in debug:

Array
(
    [type] => 2
    [message] => htmlspecialchars() expects parameter 1 to be string, object given
    [file] => /Users/jaygeorge/Sites/jaygeorge.co.uk/perch/core/lib/PerchUtil.class.php
    [line] => 169
)

Is there a simple way to make Feathers async? Or is this not possible?

Jay George

Jay George 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

'async'=>'async'

Oh wow, I didn't even realise that was valid for the script tag until I just looked it up. Thanks Drew.