简体   繁体   中英

cordova/phonegap app - load js css and html from server

I'm developing an cordova app for Android which has a lot of logic (js) and design (html/css) same as my web application. I want to share these assets among web app and android app. Now I had compiled all these js and css in apk, but when some code is changed, I have to prepare an update and put in the play store. If it would be possible to load code and css from server after app started, it would reduce need for upgrading. Is there any way?

I'm considering loading shared resources via ajax and dynamically creating stylesheets and scripts in DOM, but maybe there is better approach, isn't it?

You could download the files from server every time, but i think that is not what you want because it would not be availibe offline at all and if the app it big and the connection bad it will take much time to download.

a better way is to download the files if they change. you can do that with FileTransfer .download() yourself or use a ready solution like the cordova-standalone-hydration

BUT your app will not be accepted by for example Apple because they deny an app with code they can not check

I found a plugin where you can update all your files in the WWW folder on startup or later.

Link: https://www.npmjs.com/package/cordova-plugin-dynamic-update

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM