Include javascript in Pages/views? (Docker/Node Project)

Trying to include the necessary files for datatables.js in a Docker/Node Project Pages/ views page?

No matter what I do they are not called. Have tried including them in the layouts page, nope, in the Pages /views pages, nope… JS files and CSS in public directory… Even tried CDN… Results the same.

Please can someone explain where to include these files and in which way to do it?

Appreciated as always, thank you.

:wink:

Do I include the css/js files in the routes file for the corresponding page?

Will install from npm and try that, probably should have tried this first before posting…? New to Node so wrapping my head around it at the moment.

Just a script tag in the layout or view should be sufficient.

Have you checked in the browser developer tools if they are being downloaded? Clear cache? I feel dumb asking you these questions :disappointed:

1 Like

Totally the opposite @JonL! Am entirely new to both Node and Docker, and to chuck a third in the mix this is all on AWS. If I'm going to climb any mountain its going to be Everest, and I'll need good Sherpa's all the way!

:smiley:

There isn’t any difference being it node and docker.

Unless you are installing it via npm which you could but would need a bundler or something like browserify to make it available to the browser at build time.

In your case you are using public folder or cdn and a standard script tag in an ejs file.

1 Like

Working @JonL

Stupid newbie mistake I included public/ in the path!

Dave slaps self with frozen trout

Really appreciate the help and advice mate. Porting over a HUGE project with a ton of legacy Projects bolted on top of it, then migrating everything over to AWS from our servers and shutting those all down. Exciting, stressful, and eye opening.

:slight_smile:

1 Like

Oh yeah. Express routing will use the /public folder for static assets so it’s your root for them.

Seems like an exciting project indeed!

1 Like