eprints / irstats2

Development repository for the EPrints statistical tools
6 stars 13 forks source link

parser-blocking, cross-origin script warning on Google Chrome #85

Open photomedia opened 7 years ago

photomedia commented 7 years ago

Sometimes, abstract pages get stuck on load and/or we get the following errors on Chrome:

jsapi:22 A Parser-blocking, cross-origin script, https://www.google.com/uds/?file=visualization&v=1&packages=corechart%2Cgeochart, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details. google.loader.f @ jsapi:22 jsapi:22 A Parser-blocking, cross-origin script, https://www.google.com/uds/api/visualization/1.0/f5ce4cf7ba7513f66e3f45efe3b22ee9/format+en,default+en,ui+en,geochart+en,corechart+en.I.js, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity. See https://www.chromestatus.com/feature/5718547946799104 for more details. google.loader.f @ jsapi:22

It is related to this line:

Which is added dynamically here z_irstats2.pl:

Trigger to load the Google Charts library from the template(s)

$c->add_trigger( $EPrints::Plugin::Stats::EP_TRIGGER_DYNAMIC_TEMPLATE, sub $head->appendChild( $repo->make_javascript( 'google.load("visualization", "1", {packages:["corechart", "geochart"]});' ) );

Is that a necessary line? Why is Chrome blocking it?

graingert commented 7 years ago

eprints should avoid inline JavaScript or document.write