Including a Custom JS File

Hey everyone!

I created a Form in which I included a different JS File through the JavaScript Editor. This worked fine till today (Maybe the last update?). But now I get following error:

`

[Report Only] Refused to execute JavaScript URL because it violates the following Content Security Policy directive: "script-src 'strict-dynamic' 'unsafe-eval' 'nonce-ce04f53b-385c-4d46-871d-b48b289d7ef1' ". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.

`

Did you change some settings or why is that? Is it no longer possible to include custom JS Files? If it is possible, how?

Here is how I included the JS File:

	includeJS('https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js').always(function() {
		includeJS('https://ravensburger.sharepoint.com/sites/ValueAddedTax/SiteAssets/Description.js').always(function() {

		});
	});

function includeJS(uri) {
    var def = $.Deferred();
    var script = document.createElement('script');
    script.src = uri;
    script.onload = function() {
        def.resolve();
    }
    script.onerror = function() {
        def.reject();
    }
    document.body.appendChild(script);
    return def.promise();
}

Thanks in advance

Josh

1 Like

Dear Josh,
Nothing has changed since. Are you running Google Chrome? The error might be connected to the newest Content Security Policies - https://developer.chrome.com/extensions/contentSecurityPolicy#JSExecution

If not, other might be using it as well. It looks like an error caused by some other plugin or browser update.

Hey Nikita,

I guess you are right. I overlooked that the Script is still executed and there was an error in my custom Script.
Everything works fine now!

Thanks for your help :slight_smile: