12
Views
4
Comments
“hCaptcha script takes time to load in Reactive Web – how to optimize?”
Question
Application Type
Reactive

Hi community, 

I’m integrating hCaptcha in my Reactive Web application. The captcha works, but I notice a fraction-of-a-second delay before the hCaptcha block appears. I believe this is because the external script takes time to load. 

On screen Initialize, I’m adding: https://js.hcaptcha.com/1/api.js 

On Block Ready calling the below script

Questions: 

1. Is there a way to reduce this delay in OutSystems Reactive Web? 

2. Should I load the script in the Layout head instead of OnInitialize? 

3. How to load JavaScript offline in head tag?

 Thanks in advance! 

2023-10-16 05-50-48
Shingo Lam

Hi @Mohammad Iqbal Yusuf Sheikh ,

You can access to the https://js.hcaptcha.com/1/api.js url and save it to local js. Then, you can add it to the Scripts of the screens that need to apply the captcha.

Hope this help.

Shingo Lam

2023-10-03 13-56-29
Mohammad Iqbal Yusuf Sheikh

Hi @Shingo Lam ,

I have loaded the JavaScript locally, but the hCaptcha still takes a fraction of a second to appear.

Thank you for your response.

2023-10-16 05-50-48
Shingo Lam

In your description, you load it in the OnInitialize event. Did you save the script local in OS and attach to the screens / blocks?

If yes, is it faster than before, and you can think about minifying the script code and save it to local script instead of the full script.

2025-11-19 06-14-01
Miguel Verdasca

Hi Mohammad,

A short delay before hCaptcha appears is mostly due to the time the browser needs to download and execute the external script from https://js.hcaptcha.com. That part you cannot completely remove, but you can minimise it and avoid loading it more times than needed.


About your 3 questions:

  1. Is there a way to reduce this delay in Reactive Web? You can’t remove the network latency, but you can:

  • Load the script only once and reuse it (so subsequent screens use the cached version).

  • Load it as early as possible in the application lifecycle, instead of every time the block is used.

The delay will usually be worst only on the very first load.


  1. Should I load the script in the Layout instead of OnInitialize? Yes, that is usually a better pattern. Put the “add script tag if not present” logic in a common Layout or global block so it runs once for the whole app. Then, in your hCaptcha block, only call hcaptcha.render if window.hcaptcha already exists. This way you don’t keep injecting new tags on every screen.


  2. How to load JavaScript in the head tag? For external URLs like hCaptcha, what you are doing (creating a  element and appending it to document.head) is the correct approach. OutSystems will send your page framework, and your JS adds the script into the  at runtime. For scripts that are part of your app bundle you can also add them as script resources in the module, and OutSystems will place them in the head automatically, but for third-party URLs the pattern you’re using is fine.


In short: load the script once at layout level, rely on browser cache, and just render the captcha when window.hcaptcha is ready. That should keep the delay as small as possible.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.