Why mobile use is important
On mobile in particular, where usage is generally faster and shorter than on a desktop, a user has to wait longer to load the page. That’s why mobile users are flocking to closed apps for a better experience. A negative development if you ask us, because it goes against the open and always available nature of the web.
Only 10 to 15 percent of mobile usage takes place in a browser. On desktops this is no less than 50 percent (see this presentation by Alex Russel at Fronteers 2019). Just think of all the applications you can use in the browser, such as e-mail, social media, video platforms, word processing, chats and other (work-related) software. On mobile, web applications have never been able to make this leap to the browser.
Because the difference between mobile and desktop is so significant, Google takes an average smartphone as a starting point when testing the speed of a website. In addition, there is a good chance that a mobile score of under 40 will have a negative influence on your position in the search results.
Does rewriting require too much work? In that case, if your library supports this feature, consider loading only part of the library. This can for example be done using jQuery UI, an extension to the aforementioned jQuery-library. This extension offers the possibility to download and use only a small part. We were able to implement this for one of our clients and that made a big difference.
Another option is the use of lightweight alternatives for libraries. For example, for the jQuery code there is the much smaller Zepto.js with largely the same jQuery functions. This library is often easy to use and takes up only 26 kB, while the jQuery-library takes up no less than 86 kB.
Another example is Preact, a lightweight version of the React-library. We have now used it twice; both times successfully and almost without having to change anything in the original React code. For one client this resulted in a decrease from 452 to 292 kB (unpacked, see step 2 above). That’s a lot of savings in just three hours of work.
Block as little as possible
Only load when necessary
Execute only when necessary