开发者

how to get a minified JavaScript code from UglifyJS service using jquery.ajax()?

开发者 https://www.devze.com 2023-02-04 20:49 出处:网络
How to get a minified JavaScript code from UglifyJS service using jquery.ajax()? http://marijnhaverbeke.nl/uglifyjs/?js_code=alert(document.title)

How to get a minified JavaScript code from UglifyJS service using jquery.ajax()?

http://marijnhaverbeke.nl/uglifyjs/?js_code=alert(document.title)

The only way (are there alternative ways?) I could get successful response from the service is by using: $.ajax with dataType: "script", so it evaluates the开发者_JAVA技巧 script, but I'd like to get minified script as plain-text.

Any suggests?


You can't, since x-domain AJAX works by executing the code in a similar fasion to including a script tag:

<script src="http://marijnhaverbeke.nl/uglifyjs/?js_code=alert(document.title)"></script>

The only way you can get the minified version of the script contents is to create a proxy method on your local web server that your code can call using plain AJAX; the method only needs to forward the call to the UglifyJS service and return the string received back to the AJAX caller.

0

精彩评论

暂无评论...
验证码 换一张
取 消