Posts

Showing posts with the label Compression

Before Deployment, Is There Tool To Compress HTML Class Attribute And CSS Selectors?

Answer : If you really want to rename class names (keeping in mind what Madmartigan said) Google Closure Stylesheets does that. It's an overkill, and YUI Compressor or any other minification + gzipping tool should give you enough performance boost, but it can do it. You'll have to use other Closure tools to make appropriate changes to your .js files and html templates. There is also a project called "rename-css-selectors" if you handle the code with node: https://www.npmjs.com/package/rename-css-selectors There are plugins for nearly every build tool (webpack, parcel, gulp, ...): https://github.com/JPeer264/node-rcs-core#plugins This will minify all CSS selectors in HTML, JS and CSS files (actually any file you want). I saved 20ish% of the CSS filesize at the end. This is amazingly short-sighted. Step 1: Turn on GZip or Zlib compression in web server Step 2: All text gets compressed, often by 70% or more Step 3: There is no step 3. Step 4: PROFIT ...

Best JavaScript Compressor

Answer : I recently released UglifyJS, a JavaScript compressor which is written in JavaScript (runs on the NodeJS Node.js platform, but it can be easily modified to run on any JavaScript engine, since it doesn't need any Node.js internals). It's a lot faster than both YUI Compressor and Google Closure, it compresses better than YUI on all scripts I tested it on, and it's safer than Closure (knows to deal with "eval" or "with"). Other than whitespace removal, UglifyJS also does the following: changes local variable names (usually to single characters) joins consecutive var declarations avoids inserting any unneeded brackets, parens and semicolons optimizes IFs (removes "else" when it detects that it's not needed, transforms IFs into the &&, || or ?/: operators when possible, etc.). transforms foo["bar"] into foo.bar where possible removes quotes from keys in object literals, where possible resolves simple ...

Apache2 And Logrotate: Delaycompress Needed?

Answer : If you're doing an Apache restart (or even 'graceful') it will close open file handles and open them again. You shouldn't need delaycompress because the file will have been closed and re-opened as part of your postrotate restart. rotate access_log -> access_log.1 (rename action, no INODE change) apache still writing to access_log.1 (same open FD on same INODE) apache restart (close FD, release INODE writing) apache writing to access_log (new FD to a new INODE) A restart is kind of a bad idea - what if the config file accidentally changed and is no longer valid? Your apache won't start back up. Instead send a HUP to the parent process which tells it to close/re-open file handles. postrotate /bin/kill -HUP `cat /var/run/apache2.pid 2>/dev/null` 2>/dev/null || true endscript cat will fail if the PID is missing (or empty, or invalid) causing kill to also fail so you don't need the if..then block around it.