By using the defer attribute in HTML, the browser will load the script only after parsing (loading) the page. This can be helpful if you have a script that is dependent on other scripts, or if you want to improve the loading time of your page by loading scripts after the initial page load.
Move js 'settings' to its own file. Provide a flag to add 'defer' on all javascript files. Wrap inline code to make sure it is only executed after the page has loaded.
Motivation
By using the defer attribute in HTML, the browser will load the script only after parsing (loading) the page. This can be helpful if you have a script that is dependent on other scripts, or if you want to improve the loading time of your page by loading scripts after the initial page load.
See https://www.marketingtracer.com/seo/improve-webpage-speed-defer-javascript
Proposed Solution
Move js 'settings' to its own file. Provide a flag to add 'defer' on all javascript files. Wrap inline code to make sure it is only executed after the page has loaded.
Alternatives
None
Additional Context
No response