You should be able to load external scripts. There's a catch though; you'll have to do it in a sandboxed page that doesn't have any access to the chrome.* APIs. But you can communicate with this page through window.postMessage
Is it possible to execute a JavaScript file in a chrome packaged app?
-
02-10-2022 - |
Question
I am trying to make a Box2D TestBed structure in a Chrome app using kripken's Box2D.js. I have successfully gotten the testbed built and working you can download it from here. One of the features I would like to add to the testbed is the ability to load JavaScript files at runtime. Since chrome apps can't use eval
is there any way of loading a JavaScript file at runtime? I've tried using $.getScript
with a file:///
URL and the appropriate permissions but that doesn't work. Here are some example files that I would like to load at runtime. This is very frustrating since the program can be run on the web but not in a chrome app!
UPDATE:
I've tried using a chrome sandbox to do the evaling but I cannot pass functions through window.postMessage
. I'm beginning to lean towards hosting it on a server.
Thanks!
Solution