Inline script does not in detail view if type is set to module

I have a custom field which is a countdown timer. I set the time value inside an inline script in velocity. However, in the issue view, it works as expected but in the detail view, it doesn’t work.

issue view:

detail view:

When I change the type as “text/javascript”, it works just the opposite.

What is the difference between two pages that causes the inconsistency?

Workaround:

I have set the main script type as module to make it run in the issue view. I have also added another script which has text/javascript type in order to make it run in detail view and change the main script’s type.

        <script type="text/javascript">
            var timerScript = document.getElementById('timerScript');
            timerScript.setAttribute('type', 'text/javascript');
        </script>

        <!-- main script -->
        <script type="module" id="timerScript">