NativeScript for Mobile App Development Performance and Debugging 1 — Questions and Answers
Question 1: Which NativeScript CLI flag enables verbose logging for build diagnostics?
- --log verbose (Correct answer)
- --debug
- --verbose
- --trace
Correct answer: --log verbose
The `--log verbose` flag on ns commands prints detailed build and runtime log output for diagnosing build failures.
Question 2: Which tool allows Chrome DevTools to debug a NativeScript application?
- ns debug android (or ios) opens Chrome DevTools inspector (Correct answer)
- Xcode Instruments only
- Android Studio profiler only
- The NativeScript Playground debugger
Correct answer: ns debug android (or ios) opens Chrome DevTools inspector
`ns debug android` starts the app in debug mode and opens a Chrome DevTools session for JavaScript debugging, breakpoints, and profiling.
Question 3: What is the main performance advantage of NativeScript over hybrid frameworks like Cordova?
- Direct native API calls without a JavaScript-to-native bridge overhead (Correct answer)
- Smaller app bundle size
- Fewer permissions required
- Faster JavaScript execution engine
Correct answer: Direct native API calls without a JavaScript-to-native bridge overhead
NativeScript calls native APIs directly through its runtime without a bridge, eliminating the serialization/deserialization overhead present in bridge-based frameworks.
Question 4: Which technique reduces NativeScript app startup time by pre-initializing the JS runtime?
- Snapshot (Webpack snapshot plugin) (Correct answer)
- Tree shaking
- Code splitting
- Lazy loading
Correct answer: Snapshot (Webpack snapshot plugin)
The V8 Snapshot feature serializes the JavaScript heap after initialization so apps start from a pre-warm state, reducing cold start time significantly.
Question 5: How do you enable console.log output from a NativeScript device in the terminal?
- Run the app with ns run --log and view output in the same terminal (Correct answer)
- Use adb logcat and filter for NativeScript
- Only available through Chrome DevTools
- Pipe to a log file with --output
Correct answer: Run the app with ns run --log and view output in the same terminal
When you run `ns run android` or `ns run ios`, console.log statements from the app are automatically printed in the same terminal window.
Question 6: What NativeScript build option minifies and obfuscates JavaScript for production?
- ns build android --release (Correct answer)
- ns build android --production
- ns build android --minify
- ns build android --optimize
Correct answer: ns build android --release
The `--release` flag triggers a production build with Webpack minification, tree shaking, and app signing for release distribution.
Which NativeScript CLI flag enables verbose logging for build diagnostics?