Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Frank Goossens

    (@futtta)

    I can indeed add the filter, but I would rather;

    $bodyreplacementpayload = '<script type="text/javascript" '.$defer.'src="'.$this->url.'"></script>';
    $bodyreplacementpayload = apply_filters('autoptimize_filter_js_bodyreplacementpayload',$bodyreplacementpayload);
    
    $bodyreplacement = implode('',$this->move['first']);
    $bodyreplacement .= $bodyreplacementpayload;
    $bodyreplacement .= implode('',$this->move['last']);

    that way the filter only impacts the autoptimized JS and not the move[‘first’] stuff. What do you think?

    frank

    Thread Starter alexluncashu

    (@alexluncashu)

    Great, I tested and it works. Also, you can pass additional url parameter to the filter.

    $bodyreplacementpayload = apply_filters('autoptimize_filter_js_bodyreplacementpayload',$bodyreplacementpayload, $this->url);

    Thank you!

    Plugin Author Frank Goossens

    (@futtta)

    hmmm … I could, but that value actually is already passed, as part of the first argument (which has the default value of $bodyreplacementpayload, i.e. ‘<script type=”text/javascript” ‘.$defer.’src=”‘.$this->url.'”></script>)’?

    frank

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem when loading js before css’ is closed to new replies.