Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 990c979

Browse files
NickIlievvchimev
authored and
vchimev
committed
updated How to Build fast applications article
1 parent 8d2c096 commit 990c979

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

‎docs/best-practices/startup-times.md‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ When the `install` command finishes, you’ll have a series of scripts you can u
4343
You can go ahead and run one of the following two commands to see how much faster your apps run with the default webpack configuration in place.
4444

4545
```
46-
npm run start-android-bundle
46+
tns run android --bundle
4747
```
4848

4949
Or
5050

5151
```
52-
npm run start-ios-bundle
52+
tns run ios --bundle
5353
```
5454

5555
> **NOTE**: If you’re having trouble enabling webpack in your own apps, feel free to reach out for help on the [NativeScript community forum](https://discourse.nativescript.org/).
@@ -86,16 +86,16 @@ Webpack has a number of plugins that extend its capabilities, but perhaps the mo
8686

8787
For NativeScript apps there are two advantages to using UglifyJS. First, because UglifyJS reduces the file size of JavaScript files, it’ll also reduce the file size of your app as a whole. Second, because UglifyJS removes dead code as it minifies your code, your app will start up faster because there will be fewer JavaScript instructions for NativeScript to parse.
8888

89-
Using UglifyJS is easy too. To use UglifyJS as part of your NativeScript builds, all you need to do is add a `--uglify` flag to the scripts you ran earlier. That is, run one of the following commands.
89+
Using UglifyJS is easy too. To use UglifyJS as part of your NativeScript builds, all you need to do is add a `--env.uglify` flag to the scripts you ran earlier. That is, run one of the following commands.
9090

9191
```
92-
npm run start-android-bundle --uglify
92+
tns run android --bundle --env.uglify
9393
```
9494

9595
Or
9696

9797
```
98-
npm run start-ios-bundle --uglify
98+
tns run ios --bundle --env.uglify
9999
```
100100

101101
If you open your `vendor.js` and `bundle.js` files, you should now see compressed code that looks something like this.
@@ -125,16 +125,16 @@ Here’s the basics of how heap snapshots work: when you start up your app, norm
125125

126126
What V8 lets you do, however, is provide a so-called heap snapshot, or a previously prepared JavaScript context. In other words, instead of NativeScript fetching, parsing, and executing scripts on every startup, the NativeScript Android runtime can instead look for a previously prepared binary file that is the result of those tasks, and just use that instead—greatly reducing the amount of time it takes for your app to get up and running.
127127

128-
In NativeScript we’re integrated this process directly within our webpack build process; therefore, running a build with V8 heap snapshots enabled is as simple as adding a `--snapshot` flag to the previous step.
128+
In NativeScript we’re integrated this process directly within our webpack build process; therefore, running a build with V8 heap snapshots enabled is as simple as adding a `--env.snapshot` flag to the previous step.
129129

130130
```
131-
npm run start-android-bundle --uglify --snapshot
131+
tns run android --bundle --env.uglify --env.snapshot
132132
```
133133

134134
There are two important things to note:
135135

136136
1) Because heap snapshots are a feature of V8, you can only use this feature as part of your NativeScript Android builds. A similar feature is not available for NativeScript iOS builds.
137-
2) Under the hood, the NativeScript snapshot generator uses a V8 tool called `mksnapshot`. The `mksnapshot` tool only supports macOS and Linux, and therefore at the moment you are unable to use the `--snapshot` flag as part of your builds on Windows. On Windows-based development machine the NativeScript CLI ignores the `--snapshot` flag.
137+
2) Under the hood, the NativeScript snapshot generator uses a V8 tool called `mksnapshot`. The `mksnapshot` tool only supports macOS and Linux, and therefore at the moment you are unable to use the `--env.snapshot` flag as part of your builds on Windows. On Windows-based development machine the NativeScript CLI ignores the `--env.snapshot` flag.
138138

139139
Because heap snapshots completely avoid the need to parse and execute the vast majority of your JavaScript on startup, they tend to speed up the startup times of NativeScript apps substantially. Here’s how the NativeScript Groceries app starts up on Android with heap snapshots enabled.
140140

@@ -158,14 +158,14 @@ npm install --save-dev nativescript-dev-webpack
158158
npm install
159159
```
160160

161-
3) Run on iOS with webpackand UglifyJS enabled.
161+
3) Run on iOS with webpack, UglifyJS, and Angular Ahead-of-Time enabled.
162162

163163
```
164-
npm run start-ios-bundle --uglify
164+
tns run ios --bundle --env.uglify --env.aot
165165
```
166166

167-
4) Run on Android with webpack, UglifyJS, and V8 heap snapshot builds enabled.
167+
4) Run on Android with webpack, UglifyJS, Angular Ahead-of-Time, and V8 heap snapshot builds enabled.
168168

169169
```
170-
npm run start-android-bundle --uglify --snapshot
170+
tns run android --bundle --env.uglify --env.aot --env.snapshot
171171
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /