my webpage is running on an Apache Server, because of big CSS and JS files I want to minify/compress the files like this:
If the CSS/JS file is changed, the Server should that that changed file, compress it and save it as a new file?
How can I do that?
You can use Gulp https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md it can minify automatically anytime you modify your styles.
Related
How do you handle links to asset files generated by webpack, when you use .ejs templating engine, if file includes [contenthash] for caching files in browser?
Thanks in advance
I need to develop a plugin for Moodle, and i need to have some js and css files in plugin. But i have the next problem - how to work with them from installed plugin? Of course, i can hardcode their path via to moodle structure, but it's a very dirty and bad way. Also, i know that i can place all js and css code inline, but i think that it's a bad decision too. Is there a built-in way to serve assets from plugin? I tried to find it in documentations, but found nothing.
Thanks
I assume you want to know how to include CSS and JS files into your plugin.
You can include a JS file via the command:
$PAGE->requires->js( /relative/path/your_script.js');
You can then call a JS function once the page has been downloaded with the command:
$PAGE->requires->js_init_call ( your_JS_function_name, array_of_parameters_here, bool: on DOM ready);
For example:
$PAGE->requires->js_init_call('init', array($USER->lang), true);
Be sure to make the $PAGE available with global $PAGE;, first.
Your CSS file can be named styles.css and put into the root folder of your plugin. The file will be automatically read by the system and included. It will take precedence over (will overwrite the settings of) the system CSS files. After that you will have to reload the theme caches.
For CSS files I have created a file watcher like described in this manual. Also for JS files, see manual, which both uses the YUI Compressor
But I didn't find how to add file watchers, which minify html files (e.g. removing comments, ..). How can I automatically minify html files with PhpStorm?
I'd suggest looking at HTMLMinifier - it has CLI and thus can be set up as a file watcher, also it can be configured as Grunt task or Gulp task and executed using Grant/Gulp console
I'm trying to create a dojo build file. What do I need to add in the profile.js file to include all the .css files inside the dojo build.js file. I'm getting dijit.js and other .js files, but the dependent .css files are not getting built into the build.js file
I'm using dojo 1.8
It doesn't really make sense to ask to combine JS and CSS into a single file. JavaScript is JavaScript; CSS is CSS.
That said, you should be able to get down to as little as one CSS request by specifying cssOptimize: 'comments' in your build profile, which will strip comments from CSS files within packages the build processes, and flatten imports. As a result, each Dijit theme's main CSS file (e.g. themes/claro/claro.css) will then require only one request, rather than requests for each component.
I am on Win 7 and I want to compress my js/css files with YUI Compressor.
It uses require.js so I would like to keep the file names and folder structure same, before and after the compress.
I put the original js files into oldjs/ folder and want minified js files to be outputted into js/ folder.
Is there any way to do that?