Google Hosted Libraries

CSP for Google Hosted Libraries

CDN
Open Source
Add Package to Your CSP

Using Google Hosted Libraries with Content Security Policy

The Google Hosted Libraries is a stable, reliable, high-speed, globally available content distribution network for the most popular, open-source JavaScript libraries.

Allow these directives in your CSP, to support Google Hosted Libraries in your Content Security Policy:

script-src
  https://ajax.googleapis.com;
style-src
  ajax.googleapis.com;
img-src
  ajax.googleapis.com;
connect-src
  ajax.googleapis.com;

The main domains used by Google Hosted Libraries are:

ajax.googleapis.com

Example Content-Security-Policy violations / reports:

Using the above CSP package, will fix these errors that you may be seeing in your console logs:

script-src/script-src-elem/script-src-attrviolations

Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.0/jquery.min.js?ver=5.7.2' because it violates the following Content Security Policy directive: "script-src 'self' 'report-sample'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

script-src/script-src-elem/script-src-attrviolations

Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.0/jquery.min.js?ver=5.7.2' because it violates the following Content Security Policy directive: "script-src 'self' 'report-sample'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

script-src/script-src-elem/script-src-attrviolations

Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.0/jquery.min.js?ver=5.7.2' because it violates the following Content Security Policy directive: "script-src 'self' 'report-sample'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

style-src/style-src-elem/style-src-attrviolations

Refused to load the stylesheet 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css?ver=564865424ccbffeb14db5e7faaa3d4ab' because it violates the following Content Security Policy directive: "style-src 'self' 'report-sample'". Note that 'style-src-elem' was not explicitly set, so 'style-src' is used as a fallback.

style-src/style-src-elem/style-src-attrviolations

Refused to load the stylesheet 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css?ver=564865424ccbffeb14db5e7faaa3d4ab' because it violates the following Content Security Policy directive: "style-src 'self' 'report-sample'". Note that 'style-src-elem' was not explicitly set, so 'style-src' is used as a fallback.

font-srcviolations

Refused to load the font 'ajax.googleapis.com' because it violates the following Content Security Policy directive: "font-src 'self'"

img-srcviolations

Refused to load the image 'ajax.googleapis.com' because it violates the following Content Security Policy directive: "img-src 'self'".

frame-srcviolations

[Report Only] Refused to frame 'ajax.googleapis.com' because it violates the following Content Security Policy directive: "frame-src 'self'".

form-actionviolations

[Report Only] Refused to send form data to 'ajax.googleapis.com' because it violates the following Content Security Policy directive: "form-action 'self'".

connect-srcviolations

[Report Only] Refused to connect to 'ajax.googleapis.com' because it violates the following Content Security Policy directive: "connect-src 'self'"