You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 17, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: docs/best-practices/startup-times.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,13 +43,13 @@ When the `install` command finishes, you’ll have a series of scripts you can u
43
43
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.
44
44
45
45
```
46
-
npm run start-android-bundle
46
+
tns run android --bundle
47
47
```
48
48
49
49
Or
50
50
51
51
```
52
-
npm run start-ios-bundle
52
+
tns run ios --bundle
53
53
```
54
54
55
55
> **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
86
86
87
87
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.
88
88
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.
90
90
91
91
```
92
-
npm run start-android-bundle --uglify
92
+
tns run android --bundle --env.uglify
93
93
```
94
94
95
95
Or
96
96
97
97
```
98
-
npm run start-ios-bundle --uglify
98
+
tns run ios --bundle --env.uglify
99
99
```
100
100
101
101
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
125
125
126
126
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.
127
127
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.
129
129
130
130
```
131
-
npm run start-android-bundle --uglify --snapshot
131
+
tns run android --bundle --env.uglify --env.snapshot
132
132
```
133
133
134
134
There are two important things to note:
135
135
136
136
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.
138
138
139
139
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.
0 commit comments