La communauté HubSpot est disponible en français.

Is it possible to add javascript with defer attribute in hubspot template

Highlighted
Nouveau contributeur

Is it possible to add javascript with defer attribute in hubspot template

Répondre
0 Vote / Votes
1 RÉPONSE 1
Gestionnaire de communauté

Hi @nutanhaspe,

 

I hope all is well with you 😄

 

By defer attribute do you mean something like this:

<script defer="defer">
	//do stuff, but defer it  (runs last)
</script>

If so, I have tested it out and it works! This is the sample code that I ran:

<!doctype html>
<html lang="{{ html_lang }}" {{ html_lang_dir }}>
    <head>
        <meta charset="utf-8">
        <meta name="description" content="{{ page_meta.meta_description }}">
        <title>{{ page_meta.html_title }}</title>
        {% if site_settings.favicon_src %}<link rel="shortcut icon" href="{{ site_settings.favicon_src }}" />{% endif %}
        {{ standard_header_includes }}

    </head>

    <body>

        {{ standard_footer_includes }}
                    <script defer="defer">
      alert("helloworld");
      
      </script>
    </body>
</html>

I created a page based off this template and was able to see the alert pop up.

Répondre
0 Vote / Votes