score:0

i had same issues, but after profiling my laravel application, i found that the issue is not highcharts but my queries to database were not optimzied, so i optimezed by avoiding to use eloquent relationship or eager loading for heavy tables, you can also consider to use temporary tables,below is a sample of raw query in laravel.

public function countoutstanding()
{
    $count=  db::select("select count(1) as count from mytable");
    return array_shift($count)->count;
}

score:6

this is actually not a laravel issue. before i get into the slow load times, if you want to return a script, you need to set the correct headers.

this:

return view('highchart.gauge')->with(compact('value' , 'divname','charttitle','suffix','minvalue','maxvalue','colormin','colormed','colormax'));

should be this:

return response(view('highchart.gauge')->with(compact('value' , 'divname','charttitle','suffix','minvalue','maxvalue','colormin','colormed','colormax')), 200, ['content-type' => 'application/javascript']);

now to answer the slow load times, you are loading...12 scripts or so? in order to minimize load times, you should minimize the number of roundtrips / have fewer http requests. each browser has a max number of simultaneous http connections per server, which is what your image is illustrating. it's simultaneously loading 2 (or so?) scripts at a time.

in addition to this, you are using laravel to parse your scripts rather than just simply serving a javascript file. that's a lot of overhead. so what do you need to do?

  1. minimize http requests.
  2. if possible, just serve a file rather than having the server parse the script.

one way to minimize http requests is to send all the variables at once and then return the concatenated view. in order to concatenate views, you can just use the period like you would with strings:

return response(view(...) . view(...), 200, ['content-type' => 'application/javascript']);

another way, which i would recommend, would be to move your highchart script to your public directory. then, in your blade file, just store the variables in a javascript array. your highchart script can then loop through that and initialize the chart(s).


Related Query

More Query from same tag