Giter Club home page Giter Club logo

jscompress.com's People

Contributors

buildinteractive avatar coliff avatar ericop avatar finom avatar toddynho avatar vlucas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jscompress.com's Issues

Prototype extensions to built-in primitives are lost

When extending built-in primitives, such as String, the prototype extension is lost.

Example:

   String.prototype.trimsplit = function(delimiter) {
      return this.match(/^\s*(.*[^\s])\s*$/)[1]
                 .split(new RegExp('\\s*' + delimiter + '\\s*'));
   }

This code gets completely omitted from the compressed output.

However, when putting this code in an anonymous function, it gets correctly compressed and included:

   (function() {
      String.prototype.trimsplit = function(delimiter) {
         return this.match(/^\s*(.*[^\s])\s*$/)[1]
                    .split(new RegExp('\\s*' + delimiter + '\\s*'));
      }
   })()

Information about final size

This website is very useful, but it will be even better if the output tab could display the length in bytes of the result.

I understand this is programatically very simple, but when talking about size limitations this is very handy information.

[Exception] Immediately-invoked / Anonymous Async Functions (IIFE)

err

JSCompress does not support shorthand functions (arrow function syntax) suchlike to:

(async () => { await someAsyncFunction(); })();

ㅤ ㅤ


I know this is related/due to lack of ES6, etc. support, but it would still be great to have, (without using babel-minify ECMAScript #78), if possible...

Top-level vars no longer being shortened

In previous versions of JSCompress, top level vars would get shortened, so I took to doing some code-golf declarations at the top to squeeze out a few more bytes. However, these do not seem to be working as they used to. For example, here is the top of a large codebase I maintain:

!function(){"use strict";var _window=window,_document=document,_head=_document.head,_undefined,_null=null,_true=!0,_false=!1,_document_currentScript=_document.currentScript,_Object_prototype_toString=Object.prototype.toString,_document_querySelector=_document.querySelector.bind(_document),_document_querySelectorAll=_document.querySelectorAll.bind(_document),_Date_now=Date.now,oCoreOptions={},fnExpectedErrorHandler=function(){},oInterfaces={pub:function(){return{data:{},options:{},ui:{}}}},core=function(e,r){return r?core.mk.arr(_document_querySelectorAll(e)):_document_querySelector(e)};core.ver="0.9.2018-01-12",core.app=oInterfaces.pub(),core.lib=oInterfaces.pub(),core.resolve=function(){var e,r,t,n,o,c,i,a,s={allowFn:_true}...

As can be seen above, the first var list is being left as-is, while those in the function at the end of the sample above are shortened to var e,r,t,n,o,c,i,a,s={allowFn:_true}.... I can see the list is still being processed because _true=!0,_false=!1 are present. However, even the non-code-golf-y variables are being left unshortened, like fnExpectedErrorHandler=function(){}!?

Is this an intentional change? Should I give up on my code-golf byte squeezing or is this a bug to be fixed?

Upload doesn't work

Uploading multiple javascript files doesn't work.

Steps to reproduce:

  1. Upload single javascript file. This works,
  2. Go back to upload tab,
  3. Upload multiple files,
  4. See results - only shows last file uploaded

Bug: let and const keywords unhandled

Description

Environment: production ( https://jscompress.com/ )
Reproduces: always

It looks like let and const keywords are not handled and prevent the file from being minified.

How to reproduce

Input:

let foo = 'bar';

Output:

Unexpected token: name (foo) (line: 1, col: 4)

Expected result:

let foo="bar";

Additional information

The issue occurs in both copy-paste and file upload modes.

Duplicate issue - escaped strings get unescaped.

if (!noquotes) {
        string = string.replace(/"/g, '"');
    }

gets replaced with

if (!noquotes) {
        string = string.replace(/"/g,""");
    }

This is completely broken! " should be left alone. a double quote is not a minified version of an escaped quote, they are two different things!

ReferenceError: Symbol is not defined

JSCompress has recently stopped working.
In FireBug I get a following message:

JS ReferenceError: Symbol is not defined
...erator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done)...
app.js (line 103)

Issue when i compressed file angular 2 js on safari

I got issue when i compressed file js which is builded by angular 2 (newest version, angular 4.0), this issue happen on safari.
It will work, when i replace "let a" to "var a", "let b" to "var b" ..etc.
Thank for your reading.
screen shot 2017-04-07 at 3 00 49 pm

Site is not working?

Hey folks - I have been using the https://jscompress.com/ site for a while - thanks! Today, the tool does not seem to work - it tells me 100% compression - even on files I have compressed successfully before. Also... does it look different? You used to have the ES6 compression checkbox on the top right and that is gone. Here's hoping it was just a bad update or something...

Nodejs programmatic api

Is there an api that I can use to pass some code through and it will minify it via nodejs.

No variable rename?

I went to jscompress.com, it just deleted my line breaks
Why doesn't it rename the variables declared in the script?

TypeError: unknown: Cannot read property 'referencePaths' of undefined

The file to be compressed is quite large (1.52 MB) but I keep getting this error message (TypeError: unknown: Cannot read property 'referencePaths' of undefined) when I try to compress it on the website https://jscompress.com.

I've already searched the file thoroughly and there's nothing matching the search: referencePaths (or paths, or reference (and yes, I searched regardless of casing)).

Any reason why this happens?

132

Thanks for any responses to solve this problem.

options

this tool should has options of minify.

Adds are overlapping page content

image

The rackspace ad is over-extending it's container on the bottom, and more importantly so is the appdynamics but it's covering up your

JSCompress.com is an online javascript compressor...

paragraph. Might want to look into that.

Minified scripts break since today

Sorry I am not very familiar with github and git overall, I just use your JS compressor pretty often. I last used it yesterday or the day before that and everything was fine, but since today my script stops working after being minified. It works before minified and the minified version I backed up yesterday works too. Have you changed anything?
Sorry I'm not being specific, I just can't find what exactly breaks, since the script is minified and not readable anymore.
The site itself works, but is like super super slow, it must take at least 30 seconds to minify a script and browser just hangs/becomes not responsive in this time. Last week compressing took around 10-15 seconds and the browser wasn't hanging like that.

Update Babel

change:
@babel/plugin-proposal-class-properties

to:
@babel/plugin-syntax-class-properties

Support for the experimental syntax 'classPrivateProperties' isn't currently enabled

I enabled checkbox "ECMAScript 2022 (via babel-minify)" and get following error :

SyntaxError: unknown: Support for the experimental syntax 'classPrivateProperties' isn't currently enabled (2:3):

1 | class ClassWithPrivateField {

2 | #privateField;
| ^
3 | }
4 |
5 |

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-class-properties (https://git.io/vb4yQ) to the 'plugins' section to enable parsing.

More info on "#privateField" :
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields

Error compressing on jscompress.com - TypeError: unknown: setting getter-only property "inList"

This code is compressing successfully

var opacity_hide = 1;
for (var i = 1; i <= 10; i++){
    var opacity_hide = (10-i)/10;
    // var delaytest = 1;
}

But this code is not compressing , and prints error:

var opacity_hide = 1;
for (var i = 1; i <= 10; i++){
    var opacity_hide = (10-i)/10;
    var delaytest = 1;
}

Error:
File maintest.js: TypeError: unknown: setting getter-only property "inList"

It cause only if "ECMAScript 2019 (via babel-minify)" is checked

Lost js cause unknow error

I'm currently using your jscompress and feel so good
Today, my js code could not be compressed as usual ( I adready try both paste code and upload file)
Here my js code, can you reprocedure it and fix it

$(document).ready(function() {
$(".export-time").daterangepicker({timePicker:!1,format:"DD-MM-YYYY",separator:" -&gt; "},function(t,e,o){$(".export-time").val(t.format("DD-MM-YYYY")+" -> "+e.format("DD-MM-YYYY"))}),$(".export-time-i").click(function(){$(this).hasClass("cur-pointer")&&$(this).closest("div").find("input").focus()}),$("#modal-detail-product, #modal-detail-contract-pay, #modal-ProductOtherNewsUpdate-info").modal("hide"),sessionStorage.setItem("ValidSession",parseInt('@Session["Verify"]')),sessionStorage.setItem("PCAL",parseInt("@Model.Pcal")),"dashboard"==sessionStorage.getItem("link")&&($(".btn-primary-go-back").text("Đóng"),$(".btn-primary-go-back").attr("data-dismiss","modal").removeClass("btn-primary-go-back")),"report"==sessionStorage.getItem("link")&&($(".btn-primary-go-back, .show-export-contract,.show-export-pack, #btnUpdateContract, #btnUpdateLiteContract").remove(),sessionStorage.removeItem("link"));
if ('@Model.ContractId' > 0) {
sessionStorage.setItem('CONTRACT_VAT', '@Model.VAT');
sessionStorage.setItem('CONTRACT', '@Model.ContractId');
if(2==parseInt('@Session["Verify"]')){var verify=parseInt($("#ContractInfo").attr("verify"));2==verify?($("#ContractInfo").find(".panel-body").addClass("bg-danger"),$("#ContractInfo").find(".panel-body").css({border:"1px solid #bd0000"})):1==verify&&$.ajax({type:"POST",contentType:"application/json",url:'@Url.Action("SetContractColorChange", "ManagerContract")',data:"{ContractId:@Model.ContractId}",success:function(a){for(var t=a.split(","),e=0;e<t.length;e++)switch(t[e]){case"ClientId":$("#txtClientId").closest("div").addClass("has-error"),$("#txtClientId").addClass("bg-danger");break;case"ContractDate":$("#txtContractDate, #txtContractDateLite").closest("div").addClass("has-error"),$("#txtContractDate, #txtContractDateLite").addClass("bg-danger");break;case"ExpireDate":$("#txtExprireDate, #txtExprireDateLite").closest("div").addClass("has-error"),$("#txtExprireDate, #txtExprireDateLite").addClass("bg-danger");break;case"ContractStatus":$("#cboContractStatus").closest("div").addClass("has-error"),$("#cboContractStatus").addClass("bg-danger");break;case"SalerId":$("#txtSalerId").closest("div").addClass("has-error"),$("#txtSalerId").addClass("bg-danger");break;case"VAT":$("#txtVAT").closest("div").addClass("has-error"),$("#txtVAT").addClass("bg-danger");break;case"ContactClientId":$("#cboContactClient").closest("div").addClass("has-error"),$("#cboContactClient").addClass("bg-danger");break;case"PayDate":$("#txtPayExpireDate").closest("div").addClass("has-error"),$("#txtPayExpireDate").addClass("bg-danger");break;case"MaVungMien":$("#cboRegionSelector").closest("div").addClass("has-error"),$("#cboRegionSelector").addClass("bg-danger");break;case"Amount":$("#txtTotal, #txtTotalLite").closest("div").addClass("has-error"),$("#txtTotal, #txtTotalLite").addClass("bg-danger");break;case"SalerBookingId":$(".saler-booking-div").addClass("has-error")}}}),$("#btnExpand").trigger("click")}
$.ajax({type:"POST",contentType:"application/json",url:'@Url.Action("ViewDetailContractPayList", "ManagerContract")',data:"{ContractId:@Model.ContractId}",success:function(t){$(".content-pay-list").empty().append(t),2==parseInt('@Session["Verify"]')&&$(".content-pay-list").find("tbody > tr").each(function(){var t=$(this).attr("id");if(void 0!==t){var n=$(this),a=n.attr("verify");n.addClass("show-change-contract-pay cur-pointer"),2==parseInt(a)?(n.addClass("bg-danger"),n.find("td").css({color:"#843534"})):1==parseInt(a)&&$.ajax({type:"POST",contentType:"application/json",url:'@Url.Action("SetContractPayColorChange", "ManagerContract")',data:"{ContractPayId:"+t+"}",success:function(t){for(var a=t.split(","),e=0;e<a.length;e++)switch(a[e]){case"PlanDate":n.find(".td-plandate").addClass("text-red");break;case"ExpireDate":n.find(".td-expiredate").addClass("text-red");break;case"Amount":n.find(".set-total-amount").addClass("text-red");break;case"Note":n.find(".set-description").addClass("text-red")}}})}})}});
$('#ajax_loading').removeAttr('style');
$.ajax({type:"POST",contentType:"application/json",url:'@Url.Action("LoadContentProduct", "ManagerContract")',data:"{ContractId:@Model.ContractId}",success:function(t){$(".content-product-list").empty().append(t),DesAndPrice(),bindClick(parseInt('@Session["Verify"]'),parseInt('@HttpContext.Current.Session["CheckQuantityChild"]')),$("#ajax_loading").css("display","none"),2==parseInt('@Session["Verify"]')&&$(".content-product-list").find("tbody > tr").each(function(){var d=$(this).attr("id");if(void 0!==d){var t=$(this).attr("verify"),n=$(this),e=n.attr("class");2==parseInt(t)&&1==parseInt(n.data("news-parent"))||2==parseInt(t)&&-1==e.indexOf("nd-new")||-1==parseInt(t)&&-1<e.indexOf("nd-new")||2==parseInt(t)&&-1<$(this).find(".inline-edit-product").find("span:first").text().toLowerCase().indexOf("mới")?(n.removeAttr("style"),n.removeClass("bg-warning").addClass("bg-danger"),n.find("td").css({color:"#843534"})):1==parseInt(t)&&$.ajax({type:"POST",contentType:"application/json",url:'@Url.Action("SetProductColorChange", "ManagerContract")',data:"{ProductId:"+d.split("-")[0]+"}",success:function(t){for(var e=t.split(","),a=0;a<e.length;a++)switch(e[a]){case"FromDate":n.find("td:eq(3)").find("div:eq(0)").find("span").addClass("text-red");break;case"ToDate":n.find("td:eq(3)").find("div:eq(1)").find("span").addClass("text-red");break;case"SL":n.find("td:eq(4)").addClass("text-red");break;case"Price":n.find("td:eq(5)").addClass("text-red");break;case"Amount":n.find("td:eq(7)").addClass("text-red");break;case"Discount":n.find("td:eq(6)").addClass("text-red");break;case"AmountDetail":$(".amount-detail-"+d).find("td:eq(5)").addClass("text-red"),$(".amount-detail-"+d).find("td:eq(7)").addClass("text-red");break;case"AmountOther":$(".amount-other-"+d).find("td:eq(5)").addClass("text-red"),$(".amount-other-"+d).find("td:eq(7)").addClass("text-red");case"Label":n.find(".mark-label").addClass("text-red")}}})}}),0<parseInt("@Model.iDisplay")&&ResizeLbContract()}});
}
LoadTokenUserBoostrap()
});

http://jscompress.com/

&quot; is converted to "

example

function vaca()
{
el.find(".c-links .c-mini-tooltip-ico").tooltip({content: 'The &quot;Edit as new &quot; feature creates a copy of the current item and opens it for editing.
Don't forget to Save/Publish it after editing. The current item remains unchanged.', className: 'c-tooltip', width: '415'});
}

Compressor does not understand classes

When I try to compress a script with a class on the site (https://jscompress.com), it gives me an error. Take this simple example:

class MyClass {
    constructor(item) {
        this.item = item
    }

    thing() {
        alert(this.item)
    }
}

new MyClass()

It gives me this an error:
Unexpected token: name «MyClass», expected: punc «;» (line: 1, col: 6)

I would really like class compression, as it is supported in a lot of browsers:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes

Doesn't support arrow functions

Attempting to compress code using arrow functions gives the following error:

Unexpected token: punc ()) (line: 1, col: 9)

The code I am attempting to compress is this:

var e = () => {
	document.body.classList.add("no-scroll");
}

Please could you add support for arrow functions? I am going to have to use another compressor in the meantime.

Missing support for experimental ecmaScript syntax features.

Hi, could you please enable the following ecmaScript syntax sugar.
[Project]

File constants.mjs: SyntaxError: unknown: Support for the experimental syntax 'importMeta' isn't currently enabled (4:59):

  2 | import { fileURLToPath } from 'url';
  3 | 
> 4 | export const __home = (() => dirname(fileURLToPath(import.meta.url)))();
    |                                                           ^
  5 | 

Add @babel/plugin-syntax-import-meta (https://git.io/vbKK6) to the 'plugins' section of your Babel config to enable parsing.
File Controller.mjs: SyntaxError: unknown: Support for the experimental syntax 'classProperties' isn't currently enabled (9:11):

   7 | 
   8 | export default class Controller {
>  9 |   running = {};
     |           ^
  10 |   timeout = {};
  11 |   inputListeners = {};
  12 |   buttons = [];

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
File Controllers.mjs: SyntaxError: unknown: Support for the experimental syntax 'classProperties' isn't currently enabled (8:15):

   6 | const SupportedControllers = requireJSON(`/json/supported-controllers.json`);
   7 | export default class Controllers {
>  8 |   controllers = [];
     |               ^
   9 |   mappingSchemasInUse = {};
  10 |   constructor() {
  11 |     findSupportedControllers.bind(this)();

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.

Add Google Analytics

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-89303869-1', 'auto');
  ga('send', 'pageview');
</script>

app.js in the js folder is still missing

Hi

the app.js file in the js.folder is still missing in the download package. How to get that?

also the babel transfrom js files are missing

vendors~babelTransform-chunk-24844acb4277512e70fd.js
babelTransform-chunk-fe622da15389dffa17f3.js

please advice

Do i have to build these files myself? If so how ? Please advice.

Thank you

Unicode letters convert to unrecognized characters on ECMAScript2017

var asciiLetters = ["🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭", "🇮", "🇯", "🇰", "🇱", "🇲", "🇳", "🇴", "🇵", "🇶", "🇷", "🇸", "🇹", "🇺", "🇻", "🇼", "🇽", "🇾", "🇿"];

Minifying this results in:

var asciiLetters=["�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�","�"];

EDIT: 🔵 also converts to �.

Special chars encoding (non-ASCII)

I notice an issue with (non-ASCII) chars.

e.g.
function x()
{
return /\w/.test(ch) || ch > "\x80";
}

will compress to:
function x(){return/\w/.test(ch)||"�"<ch}

Suggestion: when clicking on output tab

It would be nice to auto select the minified content when the user clicks on the text area in the output tab. It's just one line of js.

if you have time it also be nice to have a Copy button near the download button.
This button would copy the minified version to the clipboard (zero clipboard?)
When you have the 2 buttons you may want to color one of them differently as primary one.

P.S. Great service :) I use it all the time.

P.S 2: I am wondering if there would be a business idea if you create an api that people can call curl and it returns raw minified version

You could inject a comment in the compressed file e.g.
/* compressed/minified by jscmpr.com */
jscmpr.com is available and can redirect to the main domain.

Take care,
Slavi

Error: Unexpected = symbol

The website gives an error when finding an equals symbol in a function argument list.

E.g

function example(param1, param2 = 5) {
  return param1 + param2;
}

This is accepted code for declaring a default for a function argument.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.