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

Usage #16

Open
Tadek888 opened this issue Aug 6, 2019 · 5 comments
Open

Usage #16

Tadek888 opened this issue Aug 6, 2019 · 5 comments

Comments

@Tadek888
Copy link

Tadek888 commented Aug 6, 2019

Hello!
Is there a complete online example how to use this library?
I get an error in console 'unexpected token: identifier';

@Tadek888
Copy link
Author

Tadek888 commented Aug 6, 2019

I get an error in console 'unexpected token: identifier';

I will tell you how it is in my page:
firsty i get all my source files into one with delimiter of new line '\n',
then i minify it with JSqueeze library.
In the end i use php-packer and try to store in one single file.

Files i use to minify and pack:
jquery-3.3.1.min.js
jquery-ui-1.12.1.min.js
bootstrap.bundle.4.1.2.min.js

After i minify js it works well.
Maybe you could tell me what parameters should i use to pack it fine.

require 'Packer.php'; $packer = new Tholu\Packer\Packer($js, 'Normal', true, false, true); $js_min = $packer->pack();
I use packer version 2.0.2

script in steps:

[all together]
https://static.nexusnew.advanced.iq.pl/assets/minify/index_front_list_raw.js

[all together]+[minified]
https://static.nexusnew.advanced.iq.pl/assets/minify/index_front_list_min.js

[all together]+[minified]+[packed]
https://static.nexusnew.advanced.iq.pl/assets/minify/index_front_list_pack.js

Hope you can help me.
Best regards :)

@tholu
Copy link
Owner

tholu commented Dec 5, 2019

@Tadek888 Could you solve this already?

@halixness
Copy link

halixness commented Sep 6, 2020

Same issue here. I have just packed my js files and I get the error "unexpected identifier on line 1" (the code is one line so it is hard to even find the wrong token).
I have included jquery and other js libraries in the header by using CDN sources.
I recursively pack all my js files in the source folder, what is the issue?
Code below:

                    // If file ends with .js -> obfuscate
                    if (strpos($file, '.js') !== false) {
                        
                        // Write obfuscated file
                        $js = file_get_contents($src . '/' . $file);
                        $packer = new Tholu\Packer\Packer($js, 'Normal', true, false, true);
                        $packed_js = $packer->pack();
                    
                        file_put_contents($dst . '/' . $file, $packed_js);

                    // Normal Copy
                    } else 
                        copy($src . '/' . $file, $dst . '/' . $file); 

@tholu
Copy link
Owner

tholu commented Sep 9, 2020

@halixness Can you provide the source file or a minimal failing example?

@nansouille
Copy link

hello
in my case a missing semicoln was the problem.
it seems to need realy well formated JS

@halixness warning with your line if (strpos($file, '.js') !== false)
because 'test.js.php' is working ;)

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

4 participants