Title: Script output blocking Rendering
Last modified: September 1, 2016

---

# Script output blocking Rendering

 *  [gamluca](https://wordpress.org/support/users/gamluca/)
 * (@gamluca)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/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
 * [https://wordpress.org/plugins/kk-star-ratings/](https://wordpress.org/plugins/kk-star-ratings/)

The topic ‘Script output blocking Rendering’ is closed to new replies.

 * ![](https://ps.w.org/kk-star-ratings/assets/icon-256x256.jpg?rev=2140680)
 * [kk Star Ratings - Rate Post & Collect User Feedbacks](https://wordpress.org/plugins/kk-star-ratings/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/kk-star-ratings/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/kk-star-ratings/)
 * [Active Topics](https://wordpress.org/support/plugin/kk-star-ratings/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/kk-star-ratings/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/kk-star-ratings/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [gamluca](https://wordpress.org/support/users/gamluca/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/script-output-blocking-rendering/)
 * Status: not resolved