Where to download all-in-one minifed js file ready to use? #75

Closed
meglio opened this Issue Mar 18, 2013 · 6 comments

Projects

None yet

4 participants

@meglio
meglio commented Mar 18, 2013

No description provided.

@terrafrost

I concur. A minified js would be very nice! As is if you want to do, for example, var_dump(), you need to do this:

<script src="https://raw.github.com/kvz/phpjs/master/functions/strings/echo.js"></script> <script src="https://raw.github.com/kvz/phpjs/master/functions/var/var_dump.js"></script>

One dependency isn't too bad and it does say the dependencies in the "depends on" comment in the header, but still... I'm sure there are functions out there with more dependencies. And what if you want to use a whole slew of functions from phpjs? What if you want to use var_dump and strtotime and whatever else?

@kvz
Owner
kvz commented Apr 10, 2013

I've decided that php.js should focus on just being a resource of functions, and not on distributing big packages like these.
Anybody is welcome to make compilers built on top of php.js and do with the code whatever they want, but I personally don't want to support that use-case anymore as explained in the blogpost on the 'new' site.

It's really easy to just cat a few functions and pipe that through curl & google closure, then tee that into a php.js.min.js file though. Could be just 1 line in your Makefile.
An example of piping to closure can be found here https://github.com/transloadit/jquery-sdk/blob/master/Makefile

@kvz kvz closed this Apr 10, 2013
@meglio
meglio commented Apr 10, 2013

What if I'm not a linux user at all?
Could you not do it if it is one line of code, please?

@kvz kvz reopened this Apr 10, 2013
@kvz
Owner
kvz commented Apr 10, 2013

I think curl can be installed on every platform. Tee and the pipes are not necessary so one could do this on e.g. Windows too. But here we go:

curl -sk https://raw.github.com/kvz/phpjs/master/functions/{datetime/date\
    ,array/array_diff\
    ,array/array_unique\
    ,datetime/strtotime\
    ,strings/md5\
    ,strings/vsprintf\
}.js |tee ./myphp.js && \
curl -vo ./myphp.min.js \
    -X POST \
    -H 'Expect: ' \
    --data-urlencode compilation_level="SIMPLE_OPTIMIZATIONS" \
    --data-urlencode output_format="text" \
    --data-urlencode output_info="compiled_code" \
    --data-urlencode js_code@myphp.js \
    http://closure-compiler.appspot.com/compile
  • Note that this creates myphp.js and myphp.min.js in the current directory.
  • Note that this creates a Javascript include that throws all functions in the global scope. It's recommended to put them in a dedicated phpjs object.

On a sidenote, I can recommend installing VirtualBox with Ubuntu on it so you can type some commands if you ever feel like it. It's free and makes for a powerful development asset as you can see.

Cheers

@kvz kvz closed this Apr 10, 2013
@kvz kvz was assigned Apr 10, 2013
@kvz
Owner
kvz commented May 3, 2013

A blogpost that hopefully clarifies my standing on bundling all of php.js http://phpjs.org/blog/2013/05/03/a-word-on-the-focus-of-php-dot-js/

@Theriault
Collaborator

Good post kvz
On May 3, 2013 9:19 AM, "Kevin van Zonneveld" notifications@github.com
wrote:

A blogpost that hopefully clarifies my standing on bundling all of php.js
http://phpjs.org/blog/2013/05/03/a-word-on-the-focus-of-php-dot-js/


Reply to this email directly or view it on GitHubhttps://github.com/kvz/phpjs/issues/75#issuecomment-17400006
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment