6 Ways to Make Your Apps Run Faster (without a Code Rewrite)
Here are six ways to make apps run faster, with little to no change to the underlying code.
August 3, 2020
When developers want to make their apps run faster, code optimization strategies typically first come to mind. By making your code more efficient, you usually get better performance from your app. But what if you want to improve app performance without having to overhaul the code? As this article explains, there are ways to do that, too. Below, we take a look at six methods for improving app performance with little or no change to the underlying code. In general, these tips will work for most types of apps--whether they are web apps or native apps--no matter which types of devices or operating systems they run on.
1. Ditch the splash screen.
There’s a surprising amount of debate about whether to use splash screens, those static images that pop up on the screen while an app is loading. Marketers tend to like them because they help with branding. In certain cases, they may also provide users the instant gratification they demand by displaying something before the app is loaded and ready to use.
I’d contend, however, that these benefits outweigh the drawbacks. Instead of making your users look at a splash screen for a few seconds, let them open the app and get to work as quickly as possible. Find other ways to brand the app to satisfy the marketers. And if the app takes so long to load that a splash screen is a necessary stand-in, make the app load faster in order to solve the problem. A splash screen is not a substitute for a fast app.
To put this another way: Splash screens made sense in the days of, say, Windows 98, which took so long to load that you kind of needed a splash screen to give users some assurance that, yes, the system was slowly but surely starting. But in a world where the “golden standard” for app load times is a mere second, splash screens just add unnecessary delay.
Fortunately, removing splash screens from your app is typically pretty easy. The code that handles this feature is probably pretty well segmented, so you can simply delete it (or comment it out if you’re on the fence about removing the splash screen for the long haul).
2. Use database indexing.
Even an app whose code has been optimized for speed will perform slowly if the database it depends on is inefficient. So, to make your apps run faster, make the database faster.
A full discussion of database optimization is beyond the scope of this article. However, one relatively simple trick that goes a long way toward making databases faster is to enable database indexing.
While you have to be careful not to overdo it, a well-executed database index configuration can be the difference between night and day for app performance, especially for apps that make a lot of transactions.
3. Use lazy image loading.
Virtually no app would be complete these days without images. However, the tricky thing about images is that they take a long time to load, especially for web apps, where they need to be downloaded from a remote server.
One simple way to solve this problem to make your apps run faster is “lazy” image loading, which entails loading images after the rest of an app’s content has been downloaded.
Thanks to the “loading” attribute on the tag in HTML, lazy loading is very easy to implement with only minor code modifications. To turn it on for a certain image, all you have to do is modify your code to look like this:
The lazy loading attribute can be applied to an iframe, too, making it easy to lazy-load non-critical parts of a page:
What if you want to do lazy loading for an app that is not written in HTML? That’s a bit more complicated. The method depends on which language you’re using, and it will typically require more than just trivial code modifications. However, it’s certainly possible to do lazy loading in languages like Java and Python without too much code modification.
4. Minify your code.
Code minification, which means making source code as brief as possible, is another useful technique for making apps run faster in certain contexts.
Minification is especially useful in situations where some kind of source code must be downloaded for the app to run, as is common when working with Javascript, for example. It can also come in handy if your app has dependencies that it needs to download in source-code form. By reducing the size of the source code files, you reduce download delays and make your apps run faster.
Although minification entails substantial changes to your code, it doesn’t require much effort on your part. You can simply use a tool like HTMLMinifier or cssnano to minify the code automatically before you deploy the app (or the dependency).
5. Use a CDN.
It’s harder than ever these days to know where your users will be located in a geographic sense. That makes content delivery networks, or CDNs, more useful than ever. CDNs cache copies of your app and data on servers that are physically closer to your users, reducing download delays and latency.
In the past, CDNs were practical only for development teams with big budgets. Today, however, CDNs have become quite affordable. Some providers offer free CDN services for personal apps, and you can get business-level plans for about $20 per month. The truly adventurous among us can even build their own CDNs using open source solutions like KubeCDN.
6. Run the app inside a container.
Last but not least, if you have server-side apps that you deploy inside a virtual machine, consider moving them to containers to make the apps run faster. Because containers consume fewer resources, they leave more resources available to the applications.
Repackaging a virtual machine app as a container will take some doing, but there are tools available to automate the process in certain cases. Image2Docker can convert some types of Windows applications to Docker container images, for example. VM2Docker may help do the same for Linux-based VMs, although it hasn’t been updated in a long time.
Conclusion
Application performance optimization should always begin with writing code that is as efficient as possible. But if your code is already written and you don’t have time to make major changes to it, it’s still possible to make apps run faster through small code tweaks or changes to the way you deploy the app.
About the Author
You May Also Like