Script output blocking Rendering
-
I notice that you print out che script containing var options directly whitout using the correct wordpress functions.
So i can’t optimize the code moving this script at the bottom.
I Modify the function function enqueue_js and now is working fine.
protected function enqueue_js($slug, $file, $ver = false, $prerequisite=false, $params=false, $footer = false, $json = false) { wp_enqueue_script($this->id.($slug?('_'.$slug):''), $file, is_array($prerequisite)?$prerequisite:array('jquery'), $ver ? $ver : $this->ver, $footer); if(is_array($params) && $json) { /*MOD: Luca */ wp_add_inline_script( $this->id.($slug?('_'.$slug):''), '/* <![CDATA[ */var '. str_replace('-','_',$this->id).'_'.$slug . ' = '. json_encode( $params )."/* ]]> */",1); } if(is_array($params) && !$json) wp_localize_script($this->id.($slug?('_'.$slug):''), str_replace('-','_',$this->id).'_'.$slug, $params); }
would be great if you add it in the next release.
Thanks
- The topic ‘Script output blocking Rendering’ is closed to new replies.