valmilkevich / frontcompiler Goto Github PK
View Code? Open in Web Editor NEWThis project forked from kaievns/frontcompiler
JavaScript/CSS/HTML sources compiler
License: MIT License
This project forked from kaievns/frontcompiler
JavaScript/CSS/HTML sources compiler
License: MIT License
Welcome! ======== FrontCompiler is a simple collection of compactors for the JavaScript, CSS and HTML source code. It removes trailing whitespaces, comments and transformates the local variables to make the sourcecode shorter. The library can be used as a plugin for rails. See description below. Usage ===== It's pretty simple @c = FrontCompiler.new @compact_js = @c.compact_js(File.open('src/something.js', 'r')); @compact_css = @c.compact_css(File.open('src/something.css', 'r')); @compact_html = @c.compact_html(File.open('src/something.css', 'r')); or shorter @compact_js = @c.compact_file('src/something.js'); @compact_css = @c.compact_file('src/something.css'); @compact_html = @c.compact_file('src/something.css'); or you can compact several files at once like that @library_code = @c.compact_files(%w{ src/lib.js src/lib/something.js src/lib/another.js }) Same for the other file-types CSS Inlining ============ With the tool you can convert your css source in some javascript definition so you could put the styles in the same file as your javascript and have -1 (or several) hits to your sever. File('public/javascripts/all_in_one.js', 'w') do |file| file.write @c.compact_files(%w{ public/javascripts/prototype.js public/javascripts/effects.js public/javascripts/application.js }) file.write @c.inline( File.open('public/stylesheets/application.css').read ) end Now you have a single javascript file which contains both, javascript and the application stylesheets in one. NOTE: if the user have JavaScript switched off, then he won't see the styles. Rails Usage =========== The project can be used as a usual rails plugin. Just clone the project into your vendor/plugins/front_compiler directory and you will have the following methods aviable both in your controllers and templates * compact_files(list) - compacts the files fromt the given list and puts them in a single string. You can specify a list of file-names here. * compact_file(file) - compacts the given file (can be a file-name) * compact_js(source) - returns compacted version of the given source * compact_css(source) * compact_html(source) * inline_css(source) - converts the css-source in javascript * inline_css_file(file) - converts the given css-file in a javascript source (can be a file-name) Enjoy! -- The code released under terms of the MIT License Copyright (C) 2008 Nikolay V. Nemshilov aka St.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.