Using firebase .js file in chrome extension
Using firebase .js file in chrome extension
I am developing a chrome extension that uses firebase in content script. Based on this answer I decided to store it locally in my /lib folder. Whether I download it with npm, bower or from gstatic, I always end up with binary files with chrome doesn't want to use as libraries ("Could not load file "some_filename.js" for content script. It isn't UTF-8 encoded.")
I tried converting it with iconv, Sublime, TextEdit, tried this and couple of others, nothing worked, file -I
always claims that file is binary.
file -I
Is there any other way I can obtain firebase.js file, or convert the existing binary files to utf-8?
1 Answer
1
Actually, it is not a good idea to load the firebase bundle in a content-script.
It will slow tabs loading, even if it is taken from disk. Because it still needs time to parse and process JS code.
Good practice will be to include firebase to the background page and implement a communication using messages between background and content-script.
Setting charset to utf-8 in the background page should solve the problem.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
To anyone interested, the issue with converting the firebase.js to utf-8 and workaround is explained here
– mlkwrz
Sep 20 at 9:39