0

We are loading jquery and our own javscript file after page-load as shown below:

window.addEventListener('mousemove',GetJQuery,false);

function GetJQuery(){
  var element = document.createElement("script");
  element.src = "//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js";
  document.body.appendChild(element);
  $.getScript('https://www.example.com/javascript.js'); //example.com is our site
}

We have this security policy:

Header set Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval';img-src https: data:"

Chrome is giving this error:

Refused to load the script 'javascript.js' because it violates the following Content Security Policy directive: "default-src 'self' 'unsafe-inline' 'unsafe-eval'

To my knowledge, the loading of the script should be in line with the security policy. As such, I am unable to understand the cause of the error.

Any help would be appreciated.

Cymro
  • 1,201
  • 1
  • 11
  • 29

0 Answers0