question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add local javascript script to html

See original GitHub issue

Hey, sorry if this is not the right place to ask.

I’m using PuppeteerSharp in an ASP.NET core project to generate reports. I basically generate all the html document using handlebars and then inject the whole html using SetContentAsync.

I have a local javascript library bundle (Chartjs.bundle.min) and I am not able to figure out which path I should use to make chromium see it.

I tried an absolute path, I also tried to put the library file in the same folder as chromium and reference it using ./Chartjs.bundle.js but it doesn’t seem to work.

What is the correct way to handle that.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kblokcommented, Oct 21, 2019

@psclkhoury you will need to register the js using the file protocol. It must be an absolute path but using that “path style”.

0reactions
kblokcommented, Nov 7, 2019

@psclkhoury after some reading I found that’s a security validation in Chrome. You don’t a site try to read a file from your file system.

I like your solution, you could also host that file in some server and access it using a normal url.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Including JavaScript In Your Page
Here's a very basic snippet of JavaScript using the script tag. This JavaScript is written directly into our HTML page. It will call...
Read more >
HTML script src Attribute
The src attribute specifies the URL of an external script file. If you want to run the same JavaScript on several pages in...
Read more >
What is the right way to write my script 'src' url for a local ...
This goes to the current working directory (location of index.html) and then to the js folder, and then finds the script.
Read more >
How to add a JavaScript file in HTML?
To add a JavaScript file in HTML provide your JavaScript file path to the src attribute of the <script> tag or if you...
Read more >
An Essential Guide on How to Add JavaScript to HTML - Linode
Wondering how to link javascript to HTML? Follow our step-by-step instructions, including examples, plus tips on how to add external ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found