How to make a widget load faster
Sometimes, your Elfsight widget may take a while to load on your website. This happens because our widgets are set to load after the rest of the content has loaded. This ensures that your webpage maintains optimal loading speed, avoiding any potential slowdowns.
However, if the widget is the first thing your clients see when entering the website, this feature may cause more harm than good. Fortunately, we have a solution to make the widget appear faster.
By default, every installation code has the defer
attribute. Thanks to this attribute, the script in the widget's installation code is downloaded in parallel with parsing the page and executed only after the page has finished parsing.
To make the widget appear faster, you need to replace the defer
attribute in the installation code with the async
attribute. This way, the widget's code is downloaded in parallel with parsing the page and executed as soon as it is available (before parsing completes).
Here’s an example of the installation code with the async
attribute instead of defer
:
With these changes, your widget's loading speed on your webpage should significantly improve.