简体   繁体   中英

Automatically move inline JavaScript to external file

I'm developing a Chrome App and I'd like to reuse code built for another platform. Since this code is actually a bunch of HTML and some JavaScript here and there, theoretically it would be possible to turn it in a Chrome App without (almost) any changes. The only problem I'm facing is due to in-line JavaScript , which in Chrome Apps is not allowed for security reasons.

Since I don't have full control over the generated HTML , I need a way to automatically find in-line JavaScript , move it into external files and replace it with correct references to these files.

I haven't found any tool suitable for this task. Do you know one?

Maybe something already integrated with Grunt.js or similar stuff.

Use a grunt task that parses the html code. You could use the grunt-dom-munger and define custom rules to extract the inline JavaScript.
Use the dest param to indicate where the code will be extracted.

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