Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
How to load cdn scripts in chrome extension (manifest v3) by avoiding Content Security Policy?

I have been trying to make a chrome extension which uses CDN link of Sheet.js to analyse some excel data. But getting some error related to 'Content Security Policy'.

Although I have set 'script-src-elem' explicitly in my manifest.json, but still getting following error -

Analyser.js:14 Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/xlsx.full.min.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

Analyser.js:19 Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/jszip.js' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

I have also tried to make a local of this scripts and loaded them using "web_accessible_resource", that time the scripts got added to the head without any above errors. But later I found that those scripts were not even working.

Manifest.jsom

{
    "name": "Extension",
    "description": "Trying to Learn",
    "version": "1.0",
    "manifest_version": 3,
    "permissions": [
        "storage",
        "activeTab",
        "scripting"
    ],
    "content_scripts": [
        {
            "matches": [
                "http://www.example.com/*"
            ],
            "js": [
                "Analyser.js"
            ]
        }
    ],
    "content_security_policy": {
        "extension_pages": "script-src-elem 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; script-src 'self';  object-src 'self'"
    }
}

Analyser.js

let cdnxlsx_1 = document.createElement('script');
cdnxlsx_1.src = 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/xlsx.full.min.js';
cdnxlsx_1.type = 'text/javascript';
document.head.appendChild(cdnxlsx_1);

let cdnxlsx_2 = document.createElement('script');
cdnxlsx_2.src = 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/jszip.js';
cdnxlsx_2.type = 'text/javascript';
document.head.appendChild(cdnxlsx_2);
.
.
.
.
.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!