Dynamic JavaScript loading with compression

Although I use the Zend framework, the MooTools JS library and my questions revolve around them, this is a more general question.

I am working on a web application in which I use many elements that are sometimes useful on other pages (for example, the MooTools classes associated with OpenLayers).

Mootools already allows this “segmentation” by “classifying” (by creating a “class” ..), so I feel that the next thing should be to have a separate JS file for each class, and then send a request to the PHP page with using the classes that I want and get the resulting JS file with what I need. At the same time, this mechanism will minimize both gzip and cache locally on the server (for future requests) and send me this single file.

I have not entered the design yet, and I was wondering if there is such a / similar solution? As an alternative, I see libraries like labJS that speed up multi-threaded request processing, however this does not complete the solution with minification and gzip (I have to take care of this side of the server with another additional solution).

Is anyone using a similar JS "Class" dynamic boot solution?

Cheers roman

+3
source share
3 answers

I think the tool you want to see is the Minify project . Here is the description:

Minify is a PHP5 application that helps you follow a few of Yahoo! Rules for High Performance Websites .

It combines several CSS or Javascript files, removes unnecessary spaces and comments, and serves them using gzip coding and optimal client side cache headers.

, , , http://example.com/min/, :

  • /resources/js/lib/library.js
  • /resources/js/main.js

URL:

http://example.com/min/b=resources/js&f=lib/library.js,main.js

:

<script type="text/javascript"
   src="/min/b=resources/js&amp;f=lib/library.js,main.js"></script>

, URI .

+1

zend mootools, .

, / , , ? script.

, HyperCache WP_Minify wordpress, , , .

0

, , YUI PHP Loader, JavaScript YUI. , BSD, , .

Lissa ( YUI PHP Loader), JavaScript ( CSS) .

0

Source: https://habr.com/ru/post/1723791/


All Articles