jqPlot icon indicating copy to clipboard operation
jqPlot copied to clipboard

Deprecation warning

Open ktw opened this issue 8 years ago • 3 comments

It seems that Google Chrome will begin blocking dynamic script loading, using document.write() (Used in jquery.jqplot.js) https://developers.google.com/web/updates/2016/08/removing-document-write

Chrome 58 issues a warning:

jquery.jqplot.js:66 [Violation] Avoid using document.write(). jquery.jqplot.js:66 [Violation] Parser was blocked due to document.write(

As a workaround, the list of scripts in the jquery.jplot.cs file could be loaded sequentially using the asynchronous jQuery.getScript() function. This would probably require jqplot and the plugins to communicate using some kind of ready event.

As an alternative, the scripts could be loaded using jQuery.ajax(), using the { async: false } parameter. But this method will cause other warnings, and will probably not be future proof: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests#Synchronous_request

Any better ideas out there?

ktw avatar May 23 '17 07:05 ktw

Sounds like this should definitely be looked at closer. Thanks for bringing this up!

johanbove avatar Sep 27 '18 06:09 johanbove

The dynamic loading introduces some weird debugger offset problems, visible in both Chrome and Firefox.

I am currently using Gulp to bundle the files instead of dynamically loading them via. the jquery.jqplot.js file.

Example:

{
    "outputFileName": "scripts/jqplot/jquery.jqplot.required.bundle.min.js",
    "inputFiles": [
      "scripts/jqplot/jqplot.core.js",
      "scripts/jqplot/jqplot.linearTickGenerator.js",
      "scripts/jqplot/jqplot.linearAxisRenderer.js",
      "scripts/jqplot/jqplot.axisTickRenderer.js",
      "scripts/jqplot/jqplot.axisLabelRenderer.js",
      "scripts/jqplot/jqplot.tableLegendRenderer.js",
      "scripts/jqplot/jqplot.lineRenderer.js",
      "scripts/jqplot/jqplot.markerRenderer.js",
      "scripts/jqplot/jqplot.divTitleRenderer.js",
      "scripts/jqplot/jqplot.canvasGridRenderer.js",
      "scripts/jqplot/jqplot.linePattern.js",
      "scripts/jqplot/jqplot.shadowRenderer.js",
      "scripts/jqplot/jqplot.shapeRenderer.js",
      "scripts/jqplot/jqplot.sprintf.js",
      "scripts/jqplot/jsdate.js",
      "scripts/jqplot/jqplot.themeEngine.js",
      "scripts/jqplot/jqplot.toImage.js",
      "scripts/jqplot/jqplot.effects.core.js",
      "scripts/jqplot/jqplot.effects.blind.js"
    ]
  }

And loading this file instead:

ktw avatar Sep 27 '18 09:09 ktw

Thanks for figuring this out. How would we introduce this into the main project?

johanbove avatar Sep 27 '18 09:09 johanbove