CMS Development

lica-mm
Teilnehmer/-in | Elite Partner
Teilnehmer/-in | Elite Partner

Loading Javascript files based on specific pages

lösung

Hi All,

I apologize if this has been discussed and answered elsewhere.

We are currently building out a theme (not a template) and are stuck on what the best practices are to load javascript files to specific pages.

 

In the old template structure, extra javascript files could be attached by the end-user (which was mostly us) when we were setting up the landing pages, but in the new theming structure, only css files can be attached/overridden.

 

Am I correct to assume that the "additional code snippets" are supposed to be used to add additional javascript files to the page? 

Skiier, surfer, dog lover.
0 Upvotes
1 Akzeptierte Lösung
Indra
Lösung
Ratgeber/-in | Elite Partner
Ratgeber/-in | Elite Partner

Loading Javascript files based on specific pages

lösung

Hi @lica-mm,

 

With theme development I think it's best to enbed scripts by template. You could check the HubSpot CMS Boilerplate. Within a theme you can create multiple templates. So if you need to embed scripts within landingpages, it's best to create a custom template for landingpages and add these scripts to that specific template.

 

If you have multiple landingpages but only want to load script on specific pages and not all landingpages, this should be content related. If this is so, then you still can create custom modules and attatch custom scripts inside the custom module or attach it to the custom module.

 

Hope this helps developing your theme.

If you have any thoughts about it, let me know.


Vet Digital - The Growth Agency | HubSpot Solutions Partner Agency

Did my post solve your question? Help the community by marking it as a solution

Lösung in ursprünglichem Beitrag anzeigen

1 Antwort
Indra
Lösung
Ratgeber/-in | Elite Partner
Ratgeber/-in | Elite Partner

Loading Javascript files based on specific pages

lösung

Hi @lica-mm,

 

With theme development I think it's best to enbed scripts by template. You could check the HubSpot CMS Boilerplate. Within a theme you can create multiple templates. So if you need to embed scripts within landingpages, it's best to create a custom template for landingpages and add these scripts to that specific template.

 

If you have multiple landingpages but only want to load script on specific pages and not all landingpages, this should be content related. If this is so, then you still can create custom modules and attatch custom scripts inside the custom module or attach it to the custom module.

 

Hope this helps developing your theme.

If you have any thoughts about it, let me know.


Vet Digital - The Growth Agency | HubSpot Solutions Partner Agency

Did my post solve your question? Help the community by marking it as a solution