This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-docs.git
The following commit(s) were added to refs/heads/master by this push:
new 2a8c46a936 doc: refactor next step (#1315)
2a8c46a936 is described below
commit 2a8c46a936619ee94948463c0135eefc70bd936d
Author: エリス <[email protected]>
AuthorDate: Fri May 26 21:37:10 2023 +0900
doc: refactor next step (#1315)
* doc: refactor next step
* chore: apply suggestions from code review
Co-authored-by: Niklas Merz <[email protected]>
---
www/docs/en/dev/guide/next/index.md | 110 ++++++++++++++++++++++--------------
1 file changed, 69 insertions(+), 41 deletions(-)
diff --git a/www/docs/en/dev/guide/next/index.md
b/www/docs/en/dev/guide/next/index.md
index 62f8423c56..b2348f102a 100644
--- a/www/docs/en/dev/guide/next/index.md
+++ b/www/docs/en/dev/guide/next/index.md
@@ -25,9 +25,9 @@ description: A look at topics that new Cordova developers
will encounter.
For developers who have an understanding of how to use the Cordova CLI and
make use of plugins, there are a few things you may want to consider
researching next to build better, more performant Cordova applications. The
following document offers advice on various topics relating to best practices,
testing, upgrades, and other topics, but is not meant to be prescriptive.
Consider this your launching point for your growth as a Cordova developer.
Also, if you see something that can be impro [...]
-# Best Practices for Cordova Apps
+## Best Practices for Cordova Apps
-## 1) SPA Is Your Friend
+### 1) SPA Is Your Friend
First and foremost - your Cordova applications should adopt the SPA (Single
Page Application) design. Loosely defined, a SPA is a client-side application
that is run from one request of a web page. The user loads an initial set of
resources (HTML, CSS, and JavaScript) and further updates (showing a new view,
loading data) is done via XHR requests. SPAs are commonly used for more complex
client-side applications. Gmail is a great example of this. After you load
Gmail, mail views, editing, [...]
@@ -37,47 +37,50 @@ Even if you choose not to use Cordova, creating a mobile
application without usi
Examples of SPA libraries you can use in your Cordova applications are:
-* [ReactJS](https://reactjs.org)
-* [Vue](https://vuejs.org/)
+* [React](https://react.dev/)
+* [Vue.js](https://vuejs.org/)
* [Angular](https://angular.io/)
-* [EmberJS](https://emberjs.com)
-* [Backbone](https://backbonejs.org)
+* [Ember.js](https://emberjs.com/)
+* [Backbone.js](https://backbonejs.org/)
* [Kendo UI](https://www.telerik.com/kendo-ui)
* [Onsen UI](https://onsen.io)
-* [Sencha Ext JS](https://www.sencha.com/products/extjs/)
And many, many, more.
-## 2) Performance Considerations
+### 2) Performance Considerations
Consider the following issues to improve the performance in your mobile
applications:
-**Click versus Touch** - Many devices impose a 300ms delay on click events in
order to distinguish between a tap and tap-to-zoom gesture. This can have the
effect of making your app feel slow and unresponsive. Avoiding this delay is
one of the most important ways of improving your app's perceived performance.
For more information on the tap delay, see [300ms tap delay, gone
away](https://developers.google.com/web/updates/2013/12/300ms-tap-delay-gone-away)
on the Google Developer site.
+* **Click vs. Touch**
-Most Android versions no longer impose this delay, but iOS by default still
does. For iOS, using
[WkWebView](https://github.com/apache/cordova-plugin-wkwebview-engine) instead
of the default UIWebView gets rid of this delay. For both Android and iOS, you
must ensure that your viewport meta tag has at least `width=device-width`, or
you will still have the tap delay. If you need to support older devices
(Android 4.4 or iOS 8), consider a polyfill such as
[FastClick](https://github.com/ftla [...]
+ Many devices impose a 300ms delay on click events in order to distinguish
between a tap and tap-to-zoom gesture. This can have the effect of making your
app feel slow and unresponsive. Avoiding this delay is one of the most
important ways of improving your app's perceived performance.
-**CSS Transitions versus DOM Manipulation** - Using hardware accelerated CSS
transitions will be dramatically better than using JavaScript to create
animations. See the list of resources at the end of this section for examples.
+ For more information on the tap delay, see [300ms tap delay, gone
away](https://developer.chrome.com/blog/300ms-tap-delay-gone-away/) on the
Google Developer site.
-**Networks Suck** - Ok, networks don't always suck, but the latency of mobile
networks, even good mobile networks, is far worse than you probably think. A
desktop app that slurps down 500 rows of JSON data, every 30 seconds, will be
both slower on a mobile device as well as a battery hog. Keep in mind that
Cordova apps have multiple ways to persist data in the app (LocalStorage and
the file system for example). Cache that data locally and be aware of the
amount of data you are sending ba [...]
+ As of 2015, most Android and iOS devices no longer imposes the delay. For
both Android and iOS, ensure that your viewport meta tag has set the
`width=device-width` value or you will still have the tap delay.
-**Additional Performance Articles and Resources**
+* **CSS Transitions vs. DOM Manipulation**
-* ["Fast Apps and Sites with
JavaScript"](https://channel9.msdn.com/Events/Build/2013/4-313)
+ Using hardware accelerated CSS transitions will be dramatically better
than using JavaScript to create animations. See the list of resources at the
end of this section for examples.
-## 3) Recognize and Handle Offline Status
+* **Network**
+
+ Latency of mobile networks, even good mobile networks, is far worse than
you probably think. A desktop app that slurps down 500 rows of JSON data, every
30 seconds, will be both slower on a mobile device as well as a battery hog.
Keep in mind that Cordova apps have multiple ways to persist data in the app
(LocalStorage and the file system for example). Cache that data locally and be
aware of the amount of data you are sending back and forth. This is an
especially important considerat [...]
+
+### 3) Recognize and Handle Offline Status
See the previous tip about networks. Not only can you be on a slow network, it
is entirely possible for your application to be completely offline. Your
application should handle this in an intelligent manner. If your application
does not, people will think your application is broken. Given how easy it is to
handle (Cordova supports listening for both an offline and online event), there
is absolutely no reason for your application to not respond well when run
offline. Be sure to test (see [...]
Note that the online and offline events, as well as the Network Connection
API, is not perfect. You may need to rely on using an XHR request to see if the
device is truly offline or online. At the end of the day, be sure add some form
of support for network issues - in fact, the Apple store (and probably other
stores) will reject apps that don't properly handle offline/online states. For
more discussion on this topic, see
["Is This Thing
On?"](https://www.telerik.com/blogs/is-this-thing-on-%28part-1%29)
-# Handling Upgrades
+## Handling Upgrades
-## Upgrading Cordova Projects
+### Upgrading Cordova Projects
There is no upgrade command for Cordova projects. Instead, remove the platform
from your project, and re-add it to get the latest version:
-```
+```bash
cordova platform rm android
cordova platform add android
```
@@ -86,13 +89,14 @@ It is absolutely critical that you read up on what was
changed in the updated ve
Note: some plugins may not be compatible with the new version of Cordova. If a
plugin is not compatible, you may be able to find a replacement plugin that
does what you need, or you may need to delay upgrading your project.
Alternatively, alter the plugin so that it does work under the new version and
contribute back to the community.
-## Plugin Upgrades
+### Plugin Upgrades
Upgrading plugins involves the same process as platforms - remove it, then
re-add it.
-```
+```bash
cordova plugin rm some-plugin
cordova plugin add some-plugin
```
+
Refer to [Manage versions and
platforms](../../platform_plugin_versioning_ref/index.html) for more details.
Be sure to check the updated plugin's documentation, as you may need to adjust
your code to work with the new version. Also, double check that the new version
of the plugin works with your project's version of Cordova.
@@ -101,11 +105,11 @@ Always test your apps to ensure that installing the new
plugin has not broken so
If your project has a lot of plugins that you need updated, it might save time
to create a shell or batch script that removes and adds the plugins with one
command.
-# Testing Cordova apps
+## Testing Cordova apps
Testing your applications is super important. The Cordova team uses
[Jasmine](https://jasmine.github.io/), but any web-friendly unit testing
solution will do.
-## Testing on a simulator vs. on a real device
+### Testing on a simulator vs. on a real device
It's not uncommon to use desktop browsers and device simulators/emulators when
developing a Cordova application. However, it is incredibly important that you
test your app on as many physical devices as you possibly can:
@@ -117,21 +121,24 @@ It's not uncommon to use desktop browsers and device
simulators/emulators when d
It is, of course, impossible to test on every possible device on the market.
For this reason, it's wise to recruit many testers who have different devices.
Although they won't catch every problem, chances are good that they will
discover quirks and issues that you would never find alone.
-# Debugging Cordova apps
+## Debugging Cordova apps
In most cases, debugging Cordova apps is quite straightforward.
-## iOS Debugging
+### iOS Debugging
+
+#### Xcode
-### Xcode
With Xcode you can debug the iOS native side of your Cordova application. Make
sure the Debug Area is showing (View -> Debug Area). Once your app is running
on the device (or simulator), you can view log output in the debug area. This
is where any errors or warnings will print. You can also set breakpoints within
the source files. This will allow you to step through the code one line at a
time and view the state of the variables at that time. The state of the
variables is shown in the de [...]
-### Safari Remote Debugging with Web Inspector
+#### Safari Remote Debugging with Web Inspector
+
With Safari's web inspector you can debug the webview and js code in your
Cordova application. This works only on macOS. It uses Safari to connect to
your device (or the simulator) and will connect the browser's dev tools to the
Cordova application. You get what you expect from dev tools - DOM
inspection/manipulation, a JavaScript debugger, network inspection, the
console, and more. Like Xcode, with Safari's web inspector you can set
breakpoints in the JavaScript code and view the state [...]
To start inspecting, first enable it on device at `Settings > Safari >
Advanced > Web Inspector`. On your desktop, enable the developer tools from
`Safari > Preferences > Advanced > Show Develop menu in menu bar`. In the
`Develop` menu, you will now be able to select the connected device, and the
app you want to inspect.
-## Chrome Remote Debugging
+#### Chrome Remote Debugging
+
Virtually the same as the Safari version, this works with Android only but can
be used from any desktop operating system. Once connected, you get the same
Chrome Dev Tools experience for your mobile applications as you do with your
desktop applications. Even better, the Chrome Dev Tools have a mirror option
that shows your app running on the mobile device. This is more than just a view
- you can scroll and click from dev tools and it updates on the mobile device.
To inspect, simply open up the URL `chrome://inspect` in Chrome on your
desktop. Here you will see a list of connected devices and inspectable apps.
Your device must be set up for USB debugging for this to work. Full
instructions on getting set up can be found at
[https://developers.google.com/chrome/mobile/docs/debugging](https://developers.google.com/chrome/mobile/docs/debugging).
@@ -140,7 +147,7 @@ If you can see your device in the inspect devices section,
but you can't see the
It is also possible to use Chrome Dev Tools to inspect iOS apps, through a
WebKit proxy:
[https://github.com/google/ios-webkit-debug-proxy/](https://github.com/google/ios-webkit-debug-proxy/)
-# User Interface
+## User Interface
Building a Cordova application that looks nice on mobile can be a challenge,
especially for developers. Many people chose to use a UI framework to make this
easier. Here is a short list of options you may want to consider.
@@ -155,40 +162,61 @@ When building your user interface, it is important to
think about all platforms
*
[iOS](https://developer.apple.com/design/human-interface-guidelines/ios/overview/themes/)
* [Android](https://developer.android.com/design/)
-* [Windows Phone](https://developer.microsoft.com/en-us/windows/apps/design)
-# Special Considerations
+## Special Considerations
Although Cordova makes cross-platform development easier, it's just not
possible to provide 100% isolation from the underlying native platform, so do
be aware of restrictions.
-## Platform Quirks
+### Platform Quirks
While reading the documentation, look for sections which outline different
behaviors or requirements on multiple platforms. If present, these would be in
a section titled "Android Quirks", "iOS Quirks", etc. Read through these quirks
and be aware of them as you work with Cordova.
-## Loading Remote Content
+### Loading Remote Content
Invoking Cordova JavaScript functions from a remotely-loaded HTML page (an
HTML page not stored locally on the device) is an unsupported configuration.
This is because Cordova was not designed for this, and the Apache Cordova
community does no testing of this configuration. While it can work in some
circumstances, it is not recommended nor supported. There are challenges with
the same origin policy, keeping the JavaScript and native portions of Cordova
synchronized at the same version (s [...]
The display of remotely-loaded HTML content in a webview should be done using
Cordova's InAppBrowser. The InAppBrowser is designed so that JavaScript running
there does not have access to the Cordova JavaScript APIs for the reasons
listed above. Please refer to the [Security
Guide](../appdev/security/index.html).
-# Keeping Up
+## Keeping Up
Here are a few ways to keep up to date with Cordova.
* Subscribe to the [Cordova blog](https://cordova.apache.org/blog/).
* Subscribe to the [developer list](https://cordova.apache.org/contact/). Note
- this is not a support group, but a place where development of Cordova is
discussed.
-# Getting Help
+## Getting Help
The following links are the best places to get help for Cordova:
-* Slack: [http://slack.cordova.io/](http://slack.cordova.io/) The official
Cordova Slack channel is a great way to get help from the community, and the
place you are most likely to get answers to your questions
-* StackOverflow:
[https://stackoverflow.com/questions/tagged/cordova](https://stackoverflow.com/questions/tagged/cordova)
-By using the Cordova tag, you can view and browse all Cordova questions. Note
that StackOverflow automatically converts the "Phonegap" tag to "Cordova", so
this way you will be able to access historical questions as well
-* PhoneGap Google Group:
[https://groups.google.com/forum/#!forum/phonegap](https://groups.google.com/forum/#!forum/phonegap)
-This Google Group was the old support forum when Cordova was still called
PhoneGap. While there are still a lot of Cordova users that frequently visit
this group, the Cordova community has expressed an interest in focusing less on
this group and instead using StackOverflow for support
-* Meetup: [http://phonegap.meetup.com](https://phonegap.meetup.com) -
-Consider finding a local Cordova/PhoneGap meetup group
+* [GitHub Discussions - Apache Cordova][GitHubDiscussionCommunity]
+
+ The official Apache Cordova GitHub Discussions channel is a recent
addition to our support resources, aimed at centralizing community discussions
and questions within our GitHub repositories.
+
+ This channel is highly recommended as it brings together all things
Cordova and provides the advantage of retaining a complete history of
discussions. By utilizing GitHub Discussions, we can ensure better continuity
and accessibility for future reference.
+
+* [Slack - Apache Cordova][SlackCommunity]
+
+ The official Apache Cordova Slack workspace is an excellent resource for
seeking help from the community and obtaining quick answers to your questions.
+
+ However, it's important to note that our Slack workspace does not retain
message history. This limits the accessibility of information in the long term.
To ensure better retention of your question, it is advisable to create a thread
in GitHub Discussions and share the link and a summary of your question in the
Slack.
+
+ This way, you can benefit from the immediate responsiveness of Slack while
also preserving the discussion and making it more accessible for future
reference.
+
+* [Stack Overflow - Apache Cordova](StackOverflowCommunity)
+
+ On Stack Overflow, the "cordova" tag can be used to browse all Cordova
questions.
+
+ _Note: StackOverflow automatically converts the "phonegap" tag to
"cordova" to maintain historical questions._
+
+ Stack Overflow has a vast and diverse community, making it an excellent
choice for obtaining results depending on the nature of your question. For
instance, even if you are developing a Cordova App, if your question pertains
more to web or native app development, utilizing this platform could be more
suitable. By doing so, you expose your question to a broader community that
specializes in those specific fields.
+
+* [Google Group - PhoneGap](https://groups.google.com/forum/#!forum/phonegap)
+
+ This Google Group was previously the support forum for Cordova when it was
known as PhoneGap. Although this group is currently inactive, it remains
accessible for historical reference.
+ It is advisable to utilize alternative platforms such as [GitHub
Discussions][GitHubDiscussionCommunity], [Stack
Overflow][StackOverflowCommunity], or [Slack][SlackCommunity] for obtaining
support and engaging with the Cordova community. These platforms provide more
active for assistance and discussions.
[DeviceReadyEvent]: ../../cordova/events/events.html#deviceready
+[SlackCommunity]: https://s.apache.org/cordova-slack
+[StackOverflowCommunity]: https://stackoverflow.com/questions/tagged/cordova
+[GitHubDiscussionCommunity]: https://github.com/apache/cordova/discussions
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]