sj.meyer
sj.meyer

Reputation: 885

Cordova optionally load plugin/library on install or CDN - Android & iOS

I'll explain my situation, possible solutions I've found, followed by a few questions.

I built a Cordova cross platform app, using Monaca Cloud IDE and Onsen for front-end. I'm using a slider in my app, implemented as follows:

<input type = "range" .../>

This works fine on iOS and some versions of Android, but I'm having issues with it on older Android versions. Problems I've found includes the javaScript with touchStart, touchEnd, and touchHover event doesn't fire, the thumb slider disappears, or the slider just won't do anything, like it's frozen. I've done a little bit of reading and from what I can gather there are issues with javaScript and CSS on older versions of the Android browser.

Possible solutions:

I've looked at two possible solutions (haven't tried to implement either of them), one of which is the CrossWalk web view plugin, and the other is the In-App-Browser plugin. I don't know what browser the In-App-Browser would use, but if it's not the system browser it should be a possible solution, in my mind anyway. The big issue I have with Crosswalk is the fact that it's going to make my app a lot bigger than it is without it, like at least 4-5 times +. To give you an idea, my app is only about 4MB.

Just a general note, I prefer libraries to plugins, simply because they are easier to implement, for me at least.

Questions:

Any advice, suggestions, and/or solutions is much appreciated.

Thank you.

Upvotes: 1

Views: 576

Answers (1)

Mister Smith
Mister Smith

Reputation: 28168

That widget is not fully supported in older Android versions (< 4.2). Check
http://caniuse.com/#feat=input-range

Crosswalk will solve your problem, but expect large apk sizes (my last compiled app was 41 MB). This happens because when you use XWalk you are effectively including a fully chromium browser. The core can be shared among apks though, but for a single apk you are stuck with 40+ MB.

In-App-Browser does use the standard WebView browser engine. So you won't get more from it (in fact you'll get less).

If you use a remote resource url instead of a local one for the library or css, the first time it will be downloaded, but from there on the cache will be hit (unless you disabled it in the CordovaActivity on purpose). I used this for Google Maps, and it works fine.

I'd rather use another widget to replace the one based on input range. Something will probably exist for Bootstrap or jQuery.

Upvotes: 1

Related Questions