Adam Croutworst
Adam Croutworst

Reputation: 41

How to fix UTF-8 Firebase Error for Content Script w/ Chrome Extension Manifest.json?

I made a Chrome Extension and am using Firebase to authenticate users. I downloaded the Firebase.js from https://www.gstatic.com/firebasejs/4.11.0/firebase.js, hoping to add the firebase code to my chrome extension manifest. The Firebase auth is happening in a content script, so it needs to be included in the "js" under "content_scripts".

Manifest.json Content Script Example

Instead, I'm getting a UTF-8 error when putting firebase.js.

Error: Could not load file 'js/lib/firebase.js' for content script. It isn't UTF-8 encoded. Could not load manifest.

I tried using TextEdit on Mac to save the file as UTF-8 - still not luck.

What am I doing wrong?

Upvotes: 4

Views: 1076

Answers (1)

charltoons
charltoons

Reputation: 2001

In my case, the issue stemmed from how minifiers/obfuscaters (e.g. uglify) encode certain characters. My development build worked fine, but I got this UTF8 error when I used a minified build.

Could not load file 'content-script.js' for content script. It isn't UTF-8 encoded.

For me, the solution was to disable minification.

It's an acceptable tradeoff because users aren't downloading the code from the server on every page load. It's only downloaded once when the extension is installed or updated. A little extra KB won't hurt anything.

Upvotes: 1

Related Questions