Once you have started on establishment of WordPress theme, then you have to optimize it for better user experience as well loading speed to win the market.
You have to make sure that your WordPress theme meet all necessary requirements guided by WordPress.org as well compatibility of WW3 standards before publishing it.
Here are the important tasks to optimize WordPress theme for speed and better user experience;
Use lightweight Js
You have to integrate vanilla Js for better loading speed than using Js framework, or libraries that slow down you theme during development. Do not use a lot of JQuery framework because it slows down your theme compared to standard Js. React Js also can be better choice if you want something with better DOM manipulation as JQuery.
Use fluid styling
You have to styling your assets with fluid mode to make sure that there are less layout shift on different screen such as desktop, tablet and mobile. You have to create sizes with different devices with percentage sizing or REM or EM just to make sure everything is on set.
Optimize image
You have to optimize image by integrate either lazy loading or full responsive features (auto-height, object-fit and block display units) or both. These features reduce both first-time and last-time interaction with browser, thus produce high speed with better user experience.
Reduce DOM size
You can reduce this size by omitting unnecessary containers like DIV while developing your theme. Just keep something small to reduce slow connection between HTML markup with browser.
Reduce number of global variables
As you know, global variables stand for call execution process even if the task completed which can increase php connection time compared to local variables. Local variables always exit after coding execution, thus reduce repeated requests compared to global one.
Reduce unused assets such as CSS and JS
You have to reduce execution of unused Js and CSS while developing your theme. You have to load CSS and Js on specific call-up action and not on all pages, to do this, you have divide these assets into multiple assets and enqueueing on only specific container loading.