Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running minify within a static html page #5782

Closed
denismakogon opened this issue Jan 26, 2023 · 6 comments
Closed

running minify within a static html page #5782

denismakogon opened this issue Jan 26, 2023 · 6 comments

Comments

@denismakogon
Copy link

Okay, I'm not using npm, nor running node webserver, but serving static HTML files from an object store.
So, how can I embed uglify-js into that page?

@tomasvts
Copy link

tomasvts commented Jan 31, 2023

You will have to bundle it in a single javascript file
#5764 (comment)

@denismakogon
Copy link
Author

Any chance that there will be a version that works in a browser? Or are there any alternatives that work in a browser?

@tomasvts
Copy link

tomasvts commented Jan 31, 2023

Why do you want to minify javascript in the browser?

@denismakogon
Copy link
Author

I need to compress code snippets effectively for the sake of programming language playground data effectiveness and code snippets sharing in serverless environments.

@tomasvts
Copy link

tomasvts commented Jan 31, 2023

From https://lisperator.net/uglifyjs/ :

UglifyJS2 provides a quick way to build itself for the browser:

uglifyjs --self -c -m -o /tmp/uglifyjs.js

Now you have it in /tmp/uglifyjs.js and you can include that single file in a browser.

<script src="uglify.js"></script>

If you need source maps you'll also have to include the Mozilla source-map module.

@alexlamsl
Copy link
Collaborator

Closing as answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants