CMS Development

lica-mm
参加者 | Elite Partner
参加者 | Elite Partner

Loading Javascript files based on specific pages

解決

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 いいね!
1件の承認済みベストアンサー
Indra
解決策
ガイド役 | Elite Partner
ガイド役 | Elite Partner

Loading Javascript files based on specific pages

解決

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

元の投稿で解決策を見る

1件の返信
Indra
解決策
ガイド役 | Elite Partner
ガイド役 | Elite Partner

Loading Javascript files based on specific pages

解決

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