{"id":19010328,"url":"https://github.com/railsware/web-bundler","last_synced_at":"2025-04-22T23:14:53.995Z","repository":{"id":1086237,"uuid":"936279","full_name":"railsware/web-bundler","owner":"railsware","description":"WebResourceBundler bundling particular resource (css or js) in one file. Encoding images in base64 and putting then in css directly.","archived":false,"fork":false,"pushed_at":"2011-07-04T16:44:35.000Z","size":12161,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":51,"default_branch":"master","last_synced_at":"2025-04-22T23:14:48.242Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/railsware.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-09-24T14:53:36.000Z","updated_at":"2013-10-28T08:58:58.000Z","dependencies_parsed_at":"2022-07-06T06:30:48.205Z","dependency_job_id":null,"html_url":"https://github.com/railsware/web-bundler","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsware%2Fweb-bundler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsware%2Fweb-bundler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsware%2Fweb-bundler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsware%2Fweb-bundler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/railsware","download_url":"https://codeload.github.com/railsware/web-bundler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250337950,"owners_count":21414104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T19:10:52.874Z","updated_at":"2025-04-22T23:14:53.979Z","avatar_url":"https://github.com/railsware.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[Web Resource Bundler](http://wrb.railsware.com/) - New word in resource management\n============================================\nPurpose\n------------------\nThe main purpose of WebResourceBundler gem is to minimize request \u0026 response\nround-trips count.  This could be done by bundling particular resource (css or js) in \none file. Encoding images in base64 and putting then in css directly.\n\nFunctional description\n----------------------\nWebResourceBundler parse your head html block, finding all css and js resource \nfiles.\nIt can bundle resource of particular type in one single file. Base64 filter\nencodes images in base64 putting them in css directly. Separate files for IE\nand other browsers created. Conditional comments (like `\u003c!--[if IE 6]\u003e`) also\nsupported. You can use external image hosts to server images in css: \ncdn filter can rewrite image urls for you. Resulted filename is a md5(filenames.sort)\n\nFilters\n-------\n\n+ Base64 image encoding \n+ CDN url rewriter\n+ CSS/JS compress (in master)\n  + uses yui-compressor, which requires jre\n\nInstallation\n---------------------\n\n    gem install web_resource_bundler\n\nUsage\n-------------------\n\nDeclare web_resource_bundler in your Gemfile like this:\n\n    gem web_resource_bundler\n\nAdd this two lines in your application.rb file on rails config dir:\n\n    WebResourceBundler::Bundler.setup(Rails.root, Rails.env)\n    ActionView::Base.send(:include, WebResourceBundler::RailsAppHelpers)\n\nNow in your view files you can call **`web_resource_bundler_process`** helper like this:\n\n    \u003chead\u003e\n\n    \u003c%= web_resource_bundler_process do %\u003e\n\n      \u003c%= stylesheet_link_tag :scaffold %\u003e\n      \u003c%= javascript_include_tag :defaults %\u003e\n\n    \u003c% end %\u003e\n\n    \u003c/head\u003e\n\nNotice:\n\nFor Rails \u003c 3\nyou should use **`\u003c% web_resource_bundler_process do %\u003e`**\n\nAnd For Rails \u003e= 3\nuse **`\u003c%= web_resource_bundler_process do %\u003e`**\n\n\nAnd as result you'll got something like this:\n\n    \u003chead\u003e \n      \u003c!--[if (!IE)|(gte IE 8)]\u003e\n        \u003clink href=\"/cache/cdn_base64_style_03fc490ab76c3c79d908c11cd03684ff.css?1298969608\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" /\u003e \n        \u003cscript src=\"/cache/script_4fd3a6705e370f98957d625976c96f64.js?1292848219\" type=\"text/javascript\"\u003e\u003c/script\u003e\n      \u003c![endif]--\u003e\n      \u003c!--[if lte IE 7]\u003e\n        \u003clink href=\"/cache/cdn_base64_ie_style_03fc490ab76c3c79d908c11cd03684ff.css?1298969608\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" /\u003e\n        \u003clink href=\"/cache/mhtml_style_03fc490ab76c3c79d908c11cd03684ff.mhtml?1298969608\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" /\u003e\n      \u003c![endif]--\u003e\n    \u003c/head\u003e\n\n!!!\nDon't forget to clean your cache directory after deploy to clean old bundles\n\nTo disable bundling and see raw results add no_bundler param\nmysite.com/?no_bundler=1\n\nTo configure bundler by your self you can create your custom config file - web_resource_bundler.yml\n\n/your_rails_app/config/web_resource_bundler.yml\n\n    development:\n      base64_filter:\n        use: true\n        max_image_size: 23\n      bundle_filter:\n        use: true\n      cdn_filter:\n        use: false\n        http_hosts: ['http://localhost:3000']\n        https_hosts: ['https://localhost:3000']\n      compress_filter:\n        use: true\n        obfuscate_js: true\n\nRecommendations\n--------------------\n\n1. Be mindful while organazing and linking your resource files \nWebResourceBundler combines all resource file in one. This resulted file could be huge.\n\n  * Don't link all resources in layouts!\n    Be sure to link resources (css\\js) only for pages that using them, in other case your users will be forced\n    to download huge css\\js files with unused content.\n  * One css for one page.\n    Try to slice you css files - separate file for each particular page.\n  * Separate bundle block for crucial resources\n    To make crucial resources (basic styles\\scripts for user can see basic page layout ASAP) load first - just bundle them in separate web_resource_bundler_process block and put this block at the top of your head block. \n\n2. Don't set max_image_size to big values. \nThe main reason of using Base64 filter is to avoid unnecessary server requests and minimize load time,\nbut when encoded image is very big, traffic overhead time (encoded image base64 code is bigger for apprx. 30% than source image size) could be bigger than request time. In this case your site could be even slower than without a WebResourceBundler.\nRecommended max_image_size value is 1..20kbytes\n\n3. Be careful with third party scripts.\nSome third party javascript libs can load another script file on the fly, relative path for this file computed\non the client side. But your scripts are bundled and their relative path changed (cache folder), that's why such script\nwon't be able to compute loaded file path correctly. You should avoid bundling such tricky javascripts.\n\n4. Unexistent resources handling \n\n  * Be sure to link in html only existent resource files, otherwise bundler won't work.\n  * If you have unexistent images in css, bundler will work but you've got info messages in log.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frailsware%2Fweb-bundler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frailsware%2Fweb-bundler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frailsware%2Fweb-bundler/lists"}