Cloudpage code resources - add a interactive experience that was built for our site into Cloudpage

Ashleigh Willard (Nationwide Insurance) 

I am trying to add an interactive experience that was built for our site into Cloudpage. I received the files with the code sources from my vendor and it looks as though there are 60+ .js files. Is there anything that I can do to upload this all at once or am I going to need to minify them or upload them separately. Any help or suggestions on this would be super helpful! Thank you.


Christopher Barrett (Digital Toulouse)

Hi Ashleigh, my initial thoughts are do you really need 60+ js files for your cloud page? I would imagine a few common js files like bootstrap, jquery, and some UI component libraries. Other than these types of files, on a SFMC cloud pages the number of js files isn't often that numerous. I don't know your context, but it might be worth doing an initial audit to see what you really need. If you can reduce the number of files then this will always save on maintenance and debugging. I guess when you say that you are building an "interactive experience", no doubt this would require multiple js files to build out the UI.   

 

OK, working with the fact that the number of js files is 60+, then an asset bundler could be a good option. One of the more popular ones is  webpack. It will bundle and minify your js files into a single bundle.js file. There is an initial time investment to get it setup but over the long term it may save you time with maintenance.  It is possible to also bundle up all the js files from a folder.   

On youtube there are no doubt tutorials on how to set this up. It does get a little codey, so I'm not sure if this solution is for everyone. Nevertheless, once it's mastered, it can be useful for other similar situations. 

 

Otherwise, besides the obvious approach of including the scripts tags on the 60+ js files, it could be possible to create a js file that inclues all the other files.  Here is an example of this approach to include multiple js files in a scripthttps://www.geeksforgeeks.org/how-to-include-a-javascript-file-in-another-javascript-file/


Comments

Popular posts from this blog

Data Extension and List in SFMC

What is the different email-sending options in SFMC with examples?

Difference between Journey Builder and Automation studio?