mrclay / jsmin-php Goto Github PK
View Code? Open in Web Editor NEWProvides a modified port of Douglas Crockford's jsmin.c, which removes unnecessary whitespace from JavaScript files.
License: BSD 3-Clause "New" or "Revised" License
Provides a modified port of Douglas Crockford's jsmin.c, which removes unnecessary whitespace from JavaScript files.
License: BSD 3-Clause "New" or "Revised" License
When normal JS vars are on separate lines with missing semi-colons, they are left on separate lines, but when using template literals the line-break is removed resulting in broken JS.
JS in;
// template literals without semicolons
var foo = `Hello`
foo = `world`
// template literals with semicolons
var foo = `Hello`;
foo = `world`;
// Simple strings without semicolons
var foo = 'Hello'
foo = 'world'
JS out:
var foo=`Hello`foo=`world`var foo=`Hello`;foo=`world`;var foo='Hello'
foo='world';
I report this here once more after posting it on autoptimize.
When a class contains private attributes or methods, the necessary line break or semicolon is not inserted.
As a minimum non-working example, the following class in valid JavaScript syntax does not work:
class TestClass {
#a = 3
#b = 5
#fnc1() {
do_something()
}
#fnc(2) {
do_anything()
}
}
It is minified to:
class TestClass{#a=3#b=5#fnc1(){do_something()}#fnc(2){do_anything()}}
which contains several syntax errors: There should be line breaks or semicolons between all the attributes and methods.
Assumption: The hash sign is treated the same way like an operator, and lines beginning with an operator can be appended to the preceding line.
hi @mrclay,
i was wondering, if you be interesting doing git filter branch to trim history to include only files that are jsmin-php related.
it would be probably very good idea to do that before you merge any of the PRs here.
Since PHP 7 requires that ord
function parameter passing only string type.
The original notice message:
PHP Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated
Reproduced in version: 2.4.1
- looks like fix for #10 was incomplete.
When input string ends with single line comment PHP raises deprecation warning:
ord(): Passing null to parameter #1 ($character) of type string is deprecated
at
vendor/mrclay/jsmin-php/src/JSMin/JSMin.php line 390
This problem occurs when input string ends with single line comments. Simplest test case:
\JSMin\JSMin::minify('// comment');
#1 vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(390): ord(null)
#2 vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(446): JSMin\JSMin->consumeSingleLineComment()
#3 vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(230): JSMin\JSMin->next()
#4 vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(121): JSMin\JSMin->action(3)
#5 vendor/mrclay/jsmin-php/src/JSMin/JSMin.php(86): JSMin\JSMin->min()
#6 JSMin\JSMin::minify("// comment")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.