简体   繁体   中英

Can I force chrome or another browser to use an older version of javascript?

I'm using pdfkit ( https://pypi.org/project/pdfkit/ ) to produce a pdf document from html. The html contains charts built with plotly; the plotly is driven by some javascript code from a script tag in the html.

Because pdfkit supports only an older version of javascript, I need to avoid certain newer javascript features (like let instead of var , and arrow functions). When I view the generated html in chrome, even if I've used newer javascript features, it looks fine, because chrome supports modern javascript. So I only see problems in the derived pdf document, and that makes finding the errors difficult. What I'd like to be able to do is to tell the browser to use an older version of javascript so I can see my errors in a more useful context.

Is there a way to tell chrome or some other browser to use an older version of javascript?

you can follow this https://babeljs.io/setup#installation to install babel or add babel cdn, then you need to install es2015 preset with npm install --save-dev @babel/preset-es2015 . Create.babelrc file and add following:

{
  "presets": ["@babel/preset-es2015"]
}

for more information how it works visit https://babeljs.io/repl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM